diff --git "a/data/c/data.json" "b/data/c/data.json" new file mode 100644--- /dev/null +++ "b/data/c/data.json" @@ -0,0 +1,100 @@ +{"size":206,"ext":"h","lang":"C","max_stars_count":2.0,"content":"\/\/\n\/\/ ZSUserHeadBtn.h\n\/\/ HandsUp\n\/\/\n\/\/ Created by wanghui on 2018\/6\/22.\n\/\/ Copyright \u00a9 2018\u5e74 HandsUp.Network. All rights reserved.\n\/\/\n\n#import \n\n@interface ZSUserHeadBtn : UIButton\n\n@end\n","avg_line_length":14.7142857143,"max_line_length":59,"alphanum_fraction":0.6844660194} +{"size":23370,"ext":"h","lang":"C","max_stars_count":null,"content":"\/**\n * \\file\n *\n * \\brief SAME70-XPLD Board Definition.\n *\n * Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.\n *\n * \\asf_license_start\n *\n * \\page License\n *\n * Subject to your compliance with these terms, you may use Microchip\n * software and any derivatives exclusively with Microchip products.\n * It is your responsibility to comply with third party license terms applicable\n * to your use of third party software (including open source software) that\n * may accompany Microchip software.\n *\n * THIS SOFTWARE IS SUPPLIED BY MICROCHIP \"AS IS\". NO WARRANTIES,\n * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,\n * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,\n * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE\n * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL\n * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE\n * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE\n * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT\n * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY\n * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,\n * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.\n *\n * \\asf_license_stop\n *\n *\/\n\/*\n * Support and FAQ: visit Microchip Support<\/a>\n *\/\n\n#ifndef _SAME70_XPLD_H_\n#define _SAME70_XPLD_H_\n\n#include \"compiler.h\"\n\/\/#include \"system_same70.h\"\n\nvoid system_board_init(void);\n\n\/**\n * \\page same70_xplained_pro_opfreq \"SAME70-XPLD - Operating frequencies\"\n * This page lists several definition related to the board operating frequency\n *\n * \\section Definitions\n * - \\ref BOARD_FREQ_*\n * - \\ref BOARD_MCK\n *\/\n\n\/** Board oscillator settings *\/\n#define BOARD_FREQ_SLCK_XTAL (32768U)\n#define BOARD_FREQ_SLCK_BYPASS (32768U)\n#define BOARD_FREQ_MAINCK_XTAL (12000000U)\n#define BOARD_FREQ_MAINCK_BYPASS (12000000U)\n\n\/** Master clock frequency *\/\n#define BOARD_MCK CHIP_FREQ_CPU_MAX\n\n\/** board main clock xtal statup time *\/\n#define BOARD_OSC_STARTUP_US 15625\n\n\/*----------------------------------------------------------------------------*\/\n\/**\n * \\page same70_xplained_info \"SAME70-XPLD - Board informations\"\n * This page lists several definition related to the board description.\n *\n * \\section Definitions\n * - \\ref BOARD_NAME\n *\/\n\n\/** Name of the board *\/\n#define BOARD_NAME \"SAME70-XPLD\"\n\/** Board definition *\/\n#define same70xpld\n\/** Family definition (already defined) *\/\n#define same70\n\/** Core definition *\/\n#define cortexm7\n\n\/*----------------------------------------------------------------------------*\/\n\n#define CONSOLE_UART USART1\n#define CONSOLE_UART_ID ID_USART1\n\/** USART1 pins definitions, PA21,PB4. *\/\n#define USART1_RXD_GPIO PIO_PA21_IDX\n#define USART1_RXD_FLAGS IOPORT_MODE_MUX_A\n#define USART1_TXD_GPIO PIO_PB4_IDX\n#define USART1_TXD_FLAGS IOPORT_MODE_MUX_D\n\n\/** USART0 pins definitions, PB0,PB1. *\/\n#define USART0_RXD_GPIO PIO_PB0_IDX\n#define USART0_RXD_FLAGS IOPORT_MODE_MUX_C\n#define USART0_TXD_GPIO PIO_PB1_IDX\n#define USART0_TXD_FLAGS IOPORT_MODE_MUX_C\n\n#define PIN_USART0_SCK_IDX (PIO_PB13_IDX)\n#define PIN_USART0_SCK_FLAGS (IOPORT_MODE_MUX_C)\n\n\/** USART0 pin CTS *\/\n#define PIN_USART0_CTS_IDX (PIO_PB2_IDX)\n#define PIN_USART0_CTS_FLAGS (IOPORT_MODE_MUX_C)\n\n\/** USART0 pin RTS *\/\n#define PIN_USART0_RTS_IDX (PIO_PB3_IDX)\n#define PIN_USART0_RTS_FLAGS (IOPORT_MODE_MUX_C)\n\n\n\/\/! \\name LED definitions\n\/\/@{\n#define LED0_GPIO (PIO_PC8_IDX)\n#define LED0_FLAGS (0)\n#define LED0_ACTIVE_LEVEL (IOPORT_PIN_LEVEL_LOW)\n#define LED0_INACTIVE_LEVEL (IOPORT_PIN_LEVEL_HIGH)\n\n#define\tLED_COUNT\t\t\t (1)\n\/\/@}\n\n\/\/! \\name SW0 definitions\n\/\/@{\n#define SW0_PIN (PIO_PA11_IDX)\n#define SW0_ACTIVE (IOPORT_PIN_LEVEL_LOW)\n#define SW0_INACTIVE (!SW0_ACTIVE)\n#define SW0_SUPC_INPUT 2\n\n\/**\n * Wrapper macros for SW0, to ensure common naming across all Xplained\n * boards.\n *\/\n#define PIN_SW0 {PIO_PA11, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE | PIO_IT_RISE_EDGE}\n#define PIN_SW0_MASK PIO_PA11\n#define PIN_SW0_PIO PIOA\n#define PIN_SW0_ID ID_PIOA\n#define PIN_SW0_TYPE PIO_INPUT\n#define PIN_SW0_ATTR (PIO_PULLUP | PIO_DEBOUNCE | PIO_IT_RISE_EDGE)\n\/\/@}\n\n\/**\n * \\name LED #0 definitions\n *\n * Wrapper macros for LED0, to ensure common naming across all Xplained\n * boards.\n *\/\n\/\/@{\n#define LED_0_NAME \"LED0 (yellow)\"\n#define LED_0_PIN LED0_GPIO\n#define LED_0_ACTIVE LED0_ACTIVE_LEVEL\n#define LED_0_INACTIVE LED0_INACTIVE_LEVEL\n\n#define PIN_LED_0 {PIO_PC8, PIOC, ID_PIOC, PIO_OUTPUT_1, PIO_DEFAULT}\n#define PIN_LED_0_MASK PIO_PC8\n#define PIN_LED_0_PIO PIOC\n#define PIN_LED_0_ID ID_PIOC\n#define PIN_LED_0_TYPE PIO_OUTPUT_1\n#define PIN_LED_0_ATTR PIO_DEFAULT\n\/\/@}\n\n\/* TC-- Timer Count *\/\n#define PIN_TC0_TIOA0 (PIO_PA0_IDX)\n#define PIN_TC0_TIOA0_MUX (IOPORT_MODE_MUX_B)\n#define PIN_TC0_TIOA0_FLAGS (IOPORT_MODE_MUX_B)\n\n#define PIN_TC0_TIOA0_PIO PIOA\n#define PIN_TC0_TIOA0_MASK PIO_PA0\n#define PIN_TC0_TIOA0_ID ID_PIOA\n#define PIN_TC0_TIOA0_TYPE PIO_PERIPH_B\n#define PIN_TC0_TIOA0_ATTR PIO_DEFAULT\n\n#define PIN_TC3_TIOA11\t(PIO_PD21_IDX)\n#define PIN_TC3_TIOA11_MUX\t(IOPORT_MODE_MUX_C)\n#define PIN_TC3_TIOA11_FLAGS\t(IOPORT_MODE_MUX_C)\n\n#define PIN_TC3_TIOA11_PIO\tPIOD\n#define PIN_TC3_TIOA11_MASK\tPIO_PD21\n#define PIN_TC3_TIOA11_ID\tID_PIOD\n#define PIN_TC3_TIOA11_TYPE\tPIO_PERIPH_C\n#define PIN_TC3_TIOA11_ATTR\tPIO_DEFAULT\n\n\/\/! Number of on-board LEDs\n#define BOARD_NUM_OF_LED 1\n\n\/**\n * Push button #0 definition. Attributes = pull-up + debounce + interrupt on\n * rising edge.\n *\/\n#define BUTTON_0_NAME \"SW0\"\n#define BUTTON_0_PIN SW0_PIN\n#define BUTTON_0_ACTIVE SW0_ACTIVE\n#define BUTTON_0_INACTIVE SW0_INACTIVE\n#define BUTTON_0_SUPC_INPUT SW0_SUPC_INPUT\n#define GPIO_PUSH_BUTTON_0 BUTTON_0_PIN\n\n#define PUSHBUTTON_1_NAME \"SW0\"\n#define PUSHBUTTON_1_WKUP_LINE (2)\n#define PUSHBUTTON_1_WKUP_FSTT (PMC_FSMR_FSTT2)\n#define GPIO_PUSH_BUTTON_1 (PIO_PA11_IDX)\n#define GPIO_PUSH_BUTTON_1_FLAGS (IOPORT_MODE_PULLUP | IOPORT_MODE_DEBOUNCE)\n#define GPIO_PUSH_BUTTON_1_SENSE (IOPORT_SENSE_RISING)\n\n#define PIN_PUSHBUTTON_1 {PIO_PA11, PIOA, ID_PIOA, PIO_INPUT, \\\n\t\t\t\t\t\t\t\tPIO_PULLUP | PIO_DEBOUNCE | PIO_IT_RISE_EDGE}\n#define PIN_PUSHBUTTON_1_MASK PIO_PA11\n#define PIN_PUSHBUTTON_1_PIO PIOA\n#define PIN_PUSHBUTTON_1_ID ID_PIOA\n#define PIN_PUSHBUTTON_1_TYPE PIO_INPUT\n#define PIN_PUSHBUTTON_1_ATTR (PIO_PULLUP | PIO_DEBOUNCE | PIO_IT_RISE_EDGE)\n#define PIN_PUSHBUTTON_1_IRQn PIOA_IRQn\n\n\/** List of all push button definitions. *\/\n#define PINS_PUSHBUTTONS {PIN_PUSHBUTTON_1}\n\n\/\/! \\name Extension header #1 pin definitions\n\/\/@{\n#define EXT1_PIN_3 PIO_PC31_IDX\n#define EXT1_PIN_4 PIO_PA19_IDX\n#define EXT1_PIN_5 PIO_PB3_IDX\n#define EXT1_PIN_6 PIO_PB2_IDX\n#define EXT1_PIN_7 PIO_PA0_IDX\n#define EXT1_PIN_8 PIO_PC30_IDX\n#define EXT1_PIN_9 PIO_PD28_IDX\n#define EXT1_PIN_10 PIO_PC17_IDX\n#define EXT1_PIN_11 PIO_PA3_IDX\n#define EXT1_PIN_12 PIO_PA4_IDX\n#define EXT1_PIN_13 PIO_PB0_IDX\n#define EXT1_PIN_14 PIO_PB1_IDX\n#define EXT1_PIN_15 PIO_PD25_IDX\n#define EXT1_PIN_16 PIO_PD21_IDX\n#define EXT1_PIN_17 PIO_PD20_IDX\n#define EXT1_PIN_18 PIO_PD22_IDX\n\/\/@}\n\n\/\/! \\name Extension header #1 pin definitions by function\n\/\/@{\n#define EXT1_PIN_ADC_0 EXT1_PIN_3\n#define EXT1_PIN_ADC_1 EXT1_PIN_4\n#define EXT1_PIN_GPIO_0 EXT1_PIN_5\n#define EXT1_PIN_GPIO_1 EXT1_PIN_6\n#define EXT1_PIN_PWM_0 EXT1_PIN_7\n#define EXT1_PIN_PWM_1 EXT1_PIN_8\n#define EXT1_PIN_IRQ EXT1_PIN_9\n#define EXT1_PIN_TWI_SDA EXT1_PIN_11\n#define EXT1_PIN_TWI_SCL EXT1_PIN_12\n#define EXT1_PIN_UART_RX EXT1_PIN_13\n#define EXT1_PIN_UART_TX EXT1_PIN_14\n#define EXT1_PIN_SPI_SS_1 EXT1_PIN_10\n#define EXT1_PIN_SPI_SS_0 EXT1_PIN_15\n#define EXT1_PIN_SPI_MOSI EXT1_PIN_16\n#define EXT1_PIN_SPI_MISO EXT1_PIN_17\n#define EXT1_PIN_SPI_SCK EXT1_PIN_18\n\/\/@}\n\n\/\/! \\name Extension header #2 pin definitions\n\/\/@{\n#define EXT2_PIN_3 PIO_PD30_IDX\n#define EXT2_PIN_4 PIO_PC13_IDX\n#define EXT2_PIN_5 PIO_PA6_IDX\n#define EXT2_PIN_6 PIO_PD11_IDX\n#define EXT2_PIN_7 PIO_PC19_IDX\n#define EXT2_PIN_8 PIO_PD26_IDX\n#define EXT2_PIN_9 PIO_PA2_IDX\n#define EXT2_PIN_10 PIO_PA24_IDX\n#define EXT2_PIN_11 PIO_PA3_IDX\n#define EXT2_PIN_12 PIO_PA4_IDX\n#define EXT2_PIN_13 PIO_PA21_IDX\n#define EXT2_PIN_14 PIO_PB4_IDX\n#define EXT2_PIN_15 PIO_PD27_IDX\n#define EXT2_PIN_16 PIO_PD21_IDX\n#define EXT2_PIN_17 PIO_PD20_IDX\n#define EXT2_PIN_18 PIO_PD22_IDX\n\/\/@}\n\n\/\/! \\name Extension header #2 pin definitions by function\n\/\/@{\n#define EXT2_PIN_ADC_0 EXT2_PIN_3\n#define EXT2_PIN_ADC_1 EXT2_PIN_4\n#define EXT2_PIN_GPIO_0 EXT2_PIN_5\n#define EXT2_PIN_GPIO_1 EXT2_PIN_6\n#define EXT2_PIN_PWM_0 EXT2_PIN_7\n#define EXT2_PIN_PWM_1 EXT2_PIN_8\n#define EXT2_PIN_IRQ EXT2_PIN_9\n#define EXT2_PIN_TWI_SDA EXT2_PIN_11\n#define EXT2_PIN_TWI_SCL EXT2_PIN_12\n#define EXT2_PIN_UART_RX EXT2_PIN_13\n#define EXT2_PIN_UART_TX EXT2_PIN_14\n#define EXT2_PIN_SPI_SS_1 EXT2_PIN_10\n#define EXT2_PIN_SPI_SS_0 EXT2_PIN_15\n#define EXT2_PIN_SPI_MOSI EXT2_PIN_16\n#define EXT2_PIN_SPI_MISO EXT2_PIN_17\n#define EXT2_PIN_SPI_SCK EXT2_PIN_18\n\/\/@}\n\n\/** PCK0 pin definition (PA6) *\/\n#define PIN_PCK0 (PIO_PA6_IDX)\n#define PIN_PCK0_MUX (IOPORT_MODE_MUX_B)\n#define PIN_PCK0_FLAGS (IOPORT_MODE_MUX_B)\n#define PIN_PCK0_PORT IOPORT_PIOA\n#define PIN_PCK0_MASK PIO_PA6B_PCK0\n#define PIN_PCK0_PIO PIOA\n#define PIN_PCK0_ID ID_PIOA\n#define PIN_PCK0_TYPE PIO_PERIPH_B\n#define PIN_PCK0_ATTR PIO_DEFAULT\n\n\n\/** TWI0 pins definition *\/\n#define TWIHS0_DATA_GPIO PIO_PA3_IDX\n#define TWIHS0_DATA_FLAGS (IOPORT_MODE_MUX_A)\n#define TWIHS0_CLK_GPIO PIO_PA4_IDX\n#define TWIHS0_CLK_FLAGS (IOPORT_MODE_MUX_A)\n\n\/** SPI0 pins definition *\/\n#define SPI0_MISO_GPIO PIO_PD20_IDX\n#define SPI0_MISO_FLAGS (IOPORT_MODE_MUX_B)\n#define SPI0_MOSI_GPIO PIO_PD21_IDX\n#define SPI0_MOSI_FLAGS (IOPORT_MODE_MUX_B)\n#define SPI0_NPCS0_GPIO PIO_PB2_IDX\n#define SPI0_NPCS0_FLAGS (IOPORT_MODE_MUX_D)\n#define SPI0_NPCS1_GPIO PIO_PD25_IDX\n#define SPI0_NPCS1_FLAGS (IOPORT_MODE_MUX_B)\n#define SPI0_NPCS2_GPIO PIO_PD12_IDX\n#define SPI0_NPCS2_FLAGS (IOPORT_MODE_MUX_C)\n#define SPI0_NPCS3_GPIO PIO_PD27_IDX\n#define SPI0_NPCS3_FLAGS (IOPORT_MODE_MUX_B)\n#define SPI0_SPCK_GPIO PIO_PD22_IDX\n#define SPI0_SPCK_FLAGS (IOPORT_MODE_MUX_B)\n\n\/** QSPI pins definition *\/\n#define QSPI_QSCK_GPIO PIO_PA14_IDX\n#define QSPI_QSCK_FLAGS (IOPORT_MODE_MUX_A)\n#define QSPI_QCS_GPIO PIO_PA11_IDX\n#define QSPI_QCS_FLAGS (IOPORT_MODE_MUX_A)\n#define QSPI_QIO0_GPIO PIO_PA13_IDX\n#define QSPI_QIO0_FLAGS (IOPORT_MODE_MUX_A)\n#define QSPI_QIO1_GPIO PIO_PA12_IDX\n#define QSPI_QIO1_FLAGS (IOPORT_MODE_MUX_A)\n#define QSPI_QIO2_GPIO PIO_PA17_IDX\n#define QSPI_QIO2_FLAGS (IOPORT_MODE_MUX_A)\n#define QSPI_QIO3_GPIO PIO_PD31_IDX\n#define QSPI_QIO3_FLAGS (IOPORT_MODE_MUX_A)\n\n\/** AFEC channel for potentiometer *\/\n#define AFEC_CHANNEL_POTENTIOMETER AFEC_CHANNEL_0\n\n#define MCAN_MODULE MCAN1\n\/*----------------------------------------------------------------------------*\/\n\/**\n * \\page same70_xpld_CAN \"SAME70-XPLD - CAN\"\n * This page lists definitions related to CAN0 and CAN1.\n *\n * CAN\n * - \\ref PIN_CAN0_TRANSCEIVER_RXEN\n * - \\ref PIN_CAN0_TRANSCEIVER_RS\n * - \\ref PIN_CAN0_TXD\n * - \\ref PIN_CAN0_RXD\n * - \\ref PINS_CAN0\n *\n * - \\ref PIN_CAN1_TRANSCEIVER_RXEN\n * - \\ref PIN_CAN1_TRANSCEIVER_RS\n * - \\ref PIN_CAN1_TXD\n * - \\ref PIN_CAN1_RXD\n * - \\ref PINS_CAN1\n *\/\n\/** CAN0 transceiver PIN RS. *\/\n#define PIN_CAN0_TR_RS_IDX PIO_PE0_IDX\n#define PIN_CAN0_TR_RS_FLAGS IOPORT_DIR_OUTPUT\n\n\/** CAN0 transceiver PIN EN. *\/\n#define PIN_CAN0_TR_EN_IDX PIO_PE1_IDX\n#define PIN_CAN0_TR_EN_FLAGS IOPORT_DIR_OUTPUT\n\n\/** CAN0 PIN RX. *\/\n#define PIN_CAN0_RX_IDX PIO_PB3_IDX\n#define PIN_CAN0_RX_FLAGS IOPORT_MODE_MUX_A\n\n\/** CAN0 PIN TX. *\/\n#define PIN_CAN0_TX_IDX PIO_PB2_IDX\n#define PIN_CAN0_TX_FLAGS IOPORT_MODE_MUX_A\n\n\/** CAN1 transceiver PIN RS. *\/\n#define PIN_CAN1_TR_RS_IDX PIO_PE2_IDX\n#define PIN_CAN1_TR_RS_FLAGS IOPORT_DIR_OUTPUT\n\n\/** CAN1 transceiver PIN EN. *\/\n#define PIN_CAN1_TR_EN_IDX PIO_PE3_IDX\n#define PIN_CAN1_TR_EN_FLAGS IOPORT_DIR_OUTPUT\n\n\/** CAN1 PIN RX. *\/\n#define PIN_CAN1_RX_IDX PIO_PC12_IDX\n#define PIN_CAN1_RX_FLAGS IOPORT_MODE_MUX_C\n\n\/** CAN1 PIN TX. *\/\n#define PIN_CAN1_TX_IDX PIO_PC14_IDX\n#define PIN_CAN1_TX_FLAGS IOPORT_MODE_MUX_C\n\n\/** PWM LED0 pin definitions. *\/\n#define PIN_PWM_LED0_GPIO PIO_PA23_IDX\n#define PIN_PWM_LED0_FLAGS (IOPORT_MODE_MUX_B)\n#define PIN_PWM_LED0_CHANNEL PWM_CHANNEL_0\n\n\/** PWM LED1 pin definitions. *\/\n#define PIN_PWM_LED1_GPIO PIO_PA24_IDX\n#define PIN_PWM_LED1_FLAGS (IOPORT_MODE_MUX_B)\n#define PIN_PWM_LED1_CHANNEL PWM_CHANNEL_1\n\n\/*----------------------------------------------------------------------------*\/\n\/** GMAC HW configurations *\/\n#define BOARD_GMAC_PHY_ADDR 0\n\n#define PIN_GMAC_RESET_MASK PIO_PC10\n#define PIN_GMAC_RESET_PIO PIOC\n#define PIN_GMAC_INT_MASK PIO_PA14\n#define PIN_GMAC_INT_PIO PIOA\n#define PIN_GMAC_PERIPH PIO_PERIPH_A\n#define PIN_GMAC_PIO PIOD\n#define PIN_GMAC_MASK (PIO_PD0A_GTXCK | PIO_PD1A_GTXEN | PIO_PD2A_GTX0 | \\\n\t\t\t\t\t\t PIO_PD3A_GTX1 | PIO_PD4A_GRXDV | PIO_PD5A_GRX0 | \\\n\t\t\t\t\t\t PIO_PD6A_GRX1 | PIO_PD7A_GRXER | PIO_PD8A_GMDC | \\\n\t\t\t\t\t\t PIO_PD9A_GMDIO)\n\n\/** Board configuration of the AT24MAC EEPROM *\/\n#define BOARD_AT24MAC_TWIHS TWIHS0\n\/\/#define BOARD_AT24MAC_ADDRESS (0xBE >> 1)\n#define BOARD_AT24MAC_TWIHS_CLK (400000UL)\n#define BOARD_AT24MAC_PAGE_SIZE 16\n#define BOARD_AT24MAC_TWIHS_INSTANCE TWIHS0\n#define BOARD_AT24MAC_ADDRESS (0xAE >> 1)\n#define BOARD_CLK_TWIHS_EEPROM PIO_PA4\n\n\/** HSMCI pins definition. *\/\n\/*! Number of slot connected on HSMCI interface *\/\n#define SD_MMC_HSMCI_MEM_CNT 1\n#define SD_MMC_HSMCI_SLOT_0_SIZE 4\n\/** HSMCI MCCDA pin definition. *\/\n#define PIN_HSMCI_MCCDA_GPIO (PIO_PA28_IDX)\n#define PIN_HSMCI_MCCDA_FLAGS (IOPORT_MODE_MUX_C)\n\/** HSMCI MCCK pin definition. *\/\n#define PIN_HSMCI_MCCK_GPIO (PIO_PA25_IDX)\n#define PIN_HSMCI_MCCK_FLAGS (IOPORT_MODE_MUX_D)\n\/** HSMCI MCDA0 pin definition. *\/\n#define PIN_HSMCI_MCDA0_GPIO (PIO_PA30_IDX)\n#define PIN_HSMCI_MCDA0_FLAGS (IOPORT_MODE_MUX_C)\n\/** HSMCI MCDA1 pin definition. *\/\n#define PIN_HSMCI_MCDA1_GPIO (PIO_PA31_IDX)\n#define PIN_HSMCI_MCDA1_FLAGS (IOPORT_MODE_MUX_C)\n\/** HSMCI MCDA2 pin definition. *\/\n#define PIN_HSMCI_MCDA2_GPIO (PIO_PA26_IDX)\n#define PIN_HSMCI_MCDA2_FLAGS (IOPORT_MODE_MUX_C)\n\/** HSMCI MCDA3 pin definition. *\/\n#define PIN_HSMCI_MCDA3_GPIO (PIO_PA27_IDX)\n#define PIN_HSMCI_MCDA3_FLAGS (IOPORT_MODE_MUX_C)\n\n\/** SD\/MMC card detect pin definition. *\/\n#define PIN_HSMCI_CD {PIO_PC16, PIOD, ID_PIOD, PIO_INPUT, PIO_PULLUP}\n#define SD_MMC_0_CD_GPIO (PIO_PC16_IDX)\n#define SD_MMC_0_CD_PIO_ID ID_PIOD\n#define SD_MMC_0_CD_FLAGS (IOPORT_MODE_PULLUP)\n#define SD_MMC_0_CD_DETECT_VALUE 0\n\n\/** EBI pins configuration for LCD *\/\n\/** LCD reset pin *\/\n#define PIN_EBI_RESET_MASK\t PIO_PC13\n#define PIN_EBI_RESET_PIO\t PIOC\n#define PIN_EBI_RESET_TYPE PIO_OUTPUT_1\n#define PIN_EBI_RESET_ATTRI PIO_DEFAULT\n\n\/** LCD command\/data select pin *\/\n#define PIN_EBI_CDS_MASK\t PIO_PC30\n#define PIN_EBI_CDS_PIO\t\t PIOC\n#define PIN_EBI_CDS_TYPE\t PIO_OUTPUT_1\n#define PIN_EBI_CDS_ATTRI\t PIO_DEFAULT\n\n\/** LCD data pin *\/\n#define PIN_EBI_DATAL_MASK 0xFF\n#define PIN_EBI_DATAL_PIO\t PIOC\n#define PIN_EBI_DATAL_TYPE\t PIO_PERIPH_A\n#define PIN_EBI_DATAL_ATTRI PIO_PULLUP\n\n#define PIN_EBI_DATAH_0_MASK 0x3F\n#define PIN_EBI_DATAH_0_PIO\t PIOE\n#define PIN_EBI_DATAH_0_TYPE PIO_PERIPH_A\n#define PIN_EBI_DATAH_0_ATTRI PIO_PULLUP\n\n#define PIN_EBI_DATAH_1_MASK (PIO_PA15A_D14|PIO_PA16A_D15)\n#define PIN_EBI_DATAH_1_PIO\t PIOA\n#define PIN_EBI_DATAH_1_TYPE PIO_PERIPH_A\n#define PIN_EBI_DATAH_1_ATTRI PIO_PULLUP\n\n\/** LCD WE pin *\/\n#define PIN_EBI_NWE_MASK PIO_PC8A_NWE\n#define PIN_EBI_NWE_PIO\t PIOC\n#define PIN_EBI_NWE_TYPE PIO_PERIPH_A\n#define PIN_EBI_NWE_ATTRI PIO_PULLUP\n\n\/** LCD RD pin *\/\n#define PIN_EBI_NRD_MASK PIO_PC11A_NRD\n#define PIN_EBI_NRD_PIO\t PIOC\n#define PIN_EBI_NRD_TYPE PIO_PERIPH_A\n#define PIN_EBI_NRD_ATTRI PIO_PULLUP\n\n\/** LCD CS pin (NCS3) *\/\n#define PIN_EBI_CS_MASK PIO_PD19A_NCS3\n#define PIN_EBI_CS_PIO\t PIOD\n#define PIN_EBI_CS_TYPE PIO_PERIPH_A\n#define PIN_EBI_CS_ATTRI PIO_PULLUP\n\n\/** Back-light pin definition. *\/\n#define PIN_EBI_BACKLIGHT_MASK PIO_PC9B_TIOB7\n#define PIN_EBI_BACKLIGHT_PIO\t PIOC\n#define PIN_EBI_BACKLIGHT_TYPE PIO_PERIPH_B\n#define PIN_EBI_BACKLIGHT_ATTRI PIO_DEFAULT\n\n\/*! \\name GPIO Connections of VBUS monitoring\n *\/\n\/\/! @{\n#define USB_VBUS_FLAGS (PIO_INPUT | PIO_PULLUP)\n#define USB_VBUS_PIN PIO_PC9_IDX \/* As IO pin input *\/\n#define USB_VBUS_PIN_IRQn ( PIOC_IRQn)\n#define USB_VBUS_PIO_ID ID_PIOC\n#define USB_VBUS_PIO_MASK PIO_PC9\n\/\/! @}\n\n\/*! \\name GPIO Connections of ID detecting\n *\/\n\/\/! @{\n#define USB_ID_FLAGS (PIO_INPUT | PIO_PULLUP)\n#define USB_ID_PIN PIO_PC16_IDX \/* As IO pin input *\/\n#define USB_ID_PIN_IRQn (PIOC_IRQn)\n#define USB_ID_PIO_ID ID_PIOC\n#define USB_ID_PIO_MASK PIO_PC16\n\/\/! @}\n\n\/** WM8904 Slave address *\/\n#define WM8904_SLAVE_ADDRESS (0x34 >> 1)\n\n\/** TWI interface for WM8904 *\/\n#define WM8904_TWIHS TWIHS0\n\n\/** WM8904 pins definition *\/\n#define WM8904_TK_PIO PIO_PB1_IDX\n#define WM8904_TK_FLAGS PIO_PERIPH_D\n#define WM8904_TF_PIO PIO_PB0_IDX\n#define WM8904_TF_FLAGS PIO_PERIPH_D\n#define WM8904_TD_PIO PIO_PD26_IDX\n#define WM8904_TD_FLAGS PIO_PERIPH_B\n#define WM8904_RK_PIO PIO_PA22_IDX\n#define WM8904_RK_FLAGS PIO_PERIPH_A\n#define WM8904_RF_PIO PIO_PD24_IDX\n#define WM8904_RF_FLAGS PIO_PERIPH_B\n#define WM8904_RD_PIO PIO_PA10_IDX\n#define WM8904_RD_FLAGS PIO_PERIPH_C\n#define WM8904_PCK2_PIO PIO_PA18_IDX\n#define WM8904_PCK2_FLAGS PIO_PERIPH_B\n\n\/** Board SDRAM size for MT48LC16M16A2 *\/\n#define BOARD_SDRAM_SIZE (2 * 1024 * 1024)\n\n\/** Address for transferring command bytes to the SDRAM. *\/\n#define BOARD_SDRAM_ADDR 0x70000000\n\n\/** SDRAM pins definitions *\/\n#define SDRAM_BA0_PIO PIO_PA20_IDX\n#define SDRAM_SDCK_PIO PIO_PD23_IDX\n#define SDRAM_SDCKE_PIO PIO_PD14_IDX\n#define SDRAM_SDCS_PIO PIO_PC15_IDX\n#define SDRAM_RAS_PIO PIO_PD16_IDX\n#define SDRAM_CAS_PIO PIO_PD17_IDX\n#define SDRAM_SDWE_PIO PIO_PD29_IDX\n#define SDRAM_NBS0_PIO PIO_PC18_IDX\n#define SDRAM_NBS1_PIO PIO_PD15_IDX\n#define SDRAM_A2_PIO PIO_PC20_IDX\n#define SDRAM_A3_PIO PIO_PC21_IDX\n#define SDRAM_A4_PIO PIO_PC22_IDX\n#define SDRAM_A5_PIO PIO_PC23_IDX\n#define SDRAM_A6_PIO PIO_PC24_IDX\n#define SDRAM_A7_PIO PIO_PC25_IDX\n#define SDRAM_A8_PIO PIO_PC26_IDX\n#define SDRAM_A9_PIO PIO_PC27_IDX\n#define SDRAM_A10_PIO PIO_PC28_IDX\n#define SDRAM_A11_PIO PIO_PC29_IDX\n#define SDRAM_SDA10_PIO PIO_PD13_IDX\n#define SDRAM_D0_PIO PIO_PC0_IDX\n#define SDRAM_D1_PIO PIO_PC1_IDX\n#define SDRAM_D2_PIO PIO_PC2_IDX\n#define SDRAM_D3_PIO PIO_PC3_IDX\n#define SDRAM_D4_PIO PIO_PC4_IDX\n#define SDRAM_D5_PIO PIO_PC5_IDX\n#define SDRAM_D6_PIO PIO_PC6_IDX\n#define SDRAM_D7_PIO PIO_PC7_IDX\n#define SDRAM_D8_PIO PIO_PE0_IDX\n#define SDRAM_D9_PIO PIO_PE1_IDX\n#define SDRAM_D10_PIO PIO_PE2_IDX\n#define SDRAM_D11_PIO PIO_PE3_IDX\n#define SDRAM_D12_PIO PIO_PE4_IDX\n#define SDRAM_D13_PIO PIO_PE5_IDX\n#define SDRAM_D14_PIO PIO_PA15_IDX\n#define SDRAM_D15_PIO PIO_PA16_IDX\n\n#define SDRAM_BA0_FLAGS PIO_PERIPH_C\n#define SDRAM_SDCK_FLAGS PIO_PERIPH_C\n#define SDRAM_SDCKE_FLAGS PIO_PERIPH_C\n#define SDRAM_SDCS_FLAGS PIO_PERIPH_A\n#define SDRAM_RAS_FLAGS PIO_PERIPH_C\n#define SDRAM_CAS_FLAGS PIO_PERIPH_C\n#define SDRAM_SDWE_FLAGS PIO_PERIPH_C\n#define SDRAM_NBS0_FLAGS PIO_PERIPH_A\n#define SDRAM_NBS1_FLAGS PIO_PERIPH_C\n#define SDRAM_A_FLAGS PIO_PERIPH_A\n#define SDRAM_SDA10_FLAGS PIO_PERIPH_C\n#define SDRAM_D_FLAGS PIO_PERIPH_A\n\n\/** LCD SPI configuration *\/\n#define BOARD_ILI9488_SPI SPI0\n#define BOARD_ILI9488_SPI_IRQN SPI0_IRQn\n#define BOARD_ILI9488_SPI_NPCS 3\n\n\/** LCD SPI pins definition *\/\n#define LCD_SPI_MISO_PIO PIO_PD20_IDX\n#define LCD_SPI_MISO_FLAGS (PIO_PERIPH_B | PIO_DEFAULT)\n#define LCD_SPI_MOSI_PIO PIO_PD21_IDX\n#define\tLCD_SPI_MOSI_FLAGS (PIO_PERIPH_B | PIO_DEFAULT)\n#define LCD_SPI_SPCK_PIO PIO_PD22_IDX\n#define\tLCD_SPI_SPCK_FLAGS (PIO_PERIPH_B | PIO_DEFAULT)\n#define LCD_SPI_NPCS_PIO PIO_PD27_IDX\n#define LCD_SPI_NPCS_FLAGS (PIO_PERIPH_B | PIO_DEFAULT)\n\n#define LCD_SPI_RESET_PIO PIO_PA24_IDX\n#define LCD_SPI_RESET_FLAGS (PIO_OUTPUT_1 | PIO_DEFAULT)\n#define LCD_SPI_CDS_PIO PIO_PA6_IDX\n#define\tLCD_SPI_CDS_FLAGS (PIO_OUTPUT_1 | PIO_DEFAULT)\n#define LCD_SPI_BACKLIGHT_PIO PIO_PC19_IDX\n#define\tLCD_SPI_BACKLIGHT_FLAGS (PIO_OUTPUT_1 | PIO_DEFAULT)\n\n\n\/** TWI interface for maXTouch XPRO *\/\n#define MAXTOUCH_XPRO_TWIHS TWIHS0\n\n#define MAXTOUCH_XPRO_CHG_PIO PIO_PA2_IDX\n\n\/** BNO055 external interrupt pin definition *\/\n#define PIN_BNO055_EXT_INIERRUPT {PIO_PD28, PIOD, ID_PIOD, PIO_INPUT, \\\n\t\t\t\t\t\t\t\t\t\tPIO_DEFAULT | PIO_IT_RISE_EDGE}\n#define PIN_BNO055_EXT_INIERRUPT_MASK PIO_PD28\n#define PIN_BNO055_EXT_INIERRUPT_PIO PIOD\n#define PIN_BNO055_EXT_INIERRUPT_ID ID_PIOD\n#define PIN_BNO055_EXT_INIERRUPT_TYPE PIO_INPUT\n#define PIN_BNO055_EXT_INIERRUPT_ATTR (PIO_DEFAULT | PIO_IT_RISE_EDGE)\n#define PIN_BNO055_EXT_INIERRUPT_IRQn PIOD_IRQn\n\n#define BOARD_BNO055_TWIHS TWIHS0\n#define BOARD_BNO055_ID_TWIHS ID_TWIHS0\n\n\/** TWIHS ID for simulated EEPROM application to use *\/\n#define BOARD_AT30TSE_ID_TWIHS ID_TWIHS0\n\/** TWIHS Base for simulated TWI EEPROM application to use *\/\n#define BOARD_AT30TSE_TWIHS TWIHS0\n\n\/*----------------------------------------------------------------------------*\/\n#endif \/* _SAME70_XPLD_H_ *\/\n","avg_line_length":35.3555219365,"max_line_length":103,"alphanum_fraction":0.7210954215} +{"size":1268,"ext":"h","lang":"C","max_stars_count":12.0,"content":"\/\/\n\/\/ Copyright (C) 2012 OpenSim Ltd\n\/\/\n\/\/ This program is free software; you can redistribute it and\/or\n\/\/ modify it under the terms of the GNU Lesser General Public License\n\/\/ as published by the Free Software Foundation; either version 2\n\/\/ of the License, or (at your option) any later version.\n\/\/\n\/\/ This program is distributed in the hope that it will be useful,\n\/\/ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\/\/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\/\/ GNU Lesser General Public License for more details.\n\/\/\n\/\/ You should have received a copy of the GNU Lesser General Public License\n\/\/ along with this program; if not, see .\n\/\/\n\/\/ @author: Zoltan Bojthe\n\/\/\n\n#ifndef __INET_DELAYER_H\n#define __INET_DELAYER_H\n\n#include \"inet\/common\/INETDefs.h\"\n\nnamespace inet {\n\n\/**\n * Delayer module.\n *\/\nclass INET_API Delayer : public cSimpleModule\n{\n public:\n Delayer() { delayPar = nullptr; }\n\n protected:\n virtual void initialize() override;\n virtual void handleMessage(cMessage *msg) override;\n\n cPar *delayPar;\n\n static simsignal_t rcvdPkSignal;\n static simsignal_t sentPkSignal;\n static simsignal_t delaySignal;\n};\n\n} \/\/ namespace inet\n\n#endif \/\/ ifndef __INET_DELAYER_H\n\n","avg_line_length":25.36,"max_line_length":75,"alphanum_fraction":0.7318611987} +{"size":886,"ext":"h","lang":"C","max_stars_count":4.0,"content":"\/*\n* This header is generated by classdump-dyld 1.0\n* on Wednesday, March 22, 2017 at 9:02:50 AM Mountain Standard Time\n* Operating System: Version 10.1 (Build 14U593)\n* Image Source: \/System\/Library\/Frameworks\/UIKit.framework\/UIKit\n* classdump-dyld is licensed under GPLv3, Copyright \u00a9 2013-2016 by Elias Limneos.\n*\/\n\n@class UIKBGradient;\n\n\n@protocol UIKBRenderEffect \n@property (nonatomic,readonly) BOOL isValid; \n@property (nonatomic,readonly) BOOL renderUnder; \n@property (nonatomic,readonly) SEL renderSelector; \n@property (assign,nonatomic) double weight; \n@property (nonatomic,readonly) BOOL usesRGBColors; \n@property (nonatomic,readonly) UIKBGradient * gradient; \n@required\n-(CGColorRef)CGColor;\n-(BOOL)isValid;\n-(UIKBGradient *)gradient;\n-(double)weight;\n-(BOOL)usesRGBColors;\n-(BOOL)renderUnder;\n-(SEL)renderSelector;\n-(void)setWeight:(double)arg1;\n\n@end\n\n","avg_line_length":28.5806451613,"max_line_length":81,"alphanum_fraction":0.7708803612} +{"size":455,"ext":"c","lang":"C","max_stars_count":null,"content":"#include \"trig.c\" \/\/because it's damn ugly\n\n#define abs(val) (val ^ (val >> 31)) + ((val >> 31)&1)\nfloat sin(int x) {if (x < 0) x = 360 + x;return sintab[x % 360];}\nfloat cos(int x) {if (x < 0) x = 360 + x;return costab[x % 360];}\nfloat tan(int x) {if (x < 0) x = 360 + x;return tantab[x % 360];}\n\n\/\/ sqrt via newton's approximation\nfloat sqrt(float val) {\n\tfloat ret;\n\t__asm__(\"sqrt.s %[out], %[in]\" : [out] \"=f\" (ret) : [in] \"f\" (val));\n\treturn ret;\n}\n\n","avg_line_length":30.3333333333,"max_line_length":69,"alphanum_fraction":0.567032967} +{"size":447,"ext":"h","lang":"C","max_stars_count":4.0,"content":"\/*\n* This header is generated by classdump-dyld 1.0\n* on Wednesday, March 22, 2017 at 9:09:20 AM Mountain Standard Time\n* Operating System: Version 10.1 (Build 14U593)\n* Image Source: \/System\/Library\/PrivateFrameworks\/CoreInterest.framework\/CoreInterest\n* classdump-dyld is licensed under GPLv3, Copyright \u00a9 2013-2016 by Elias Limneos.\n*\/\n\n\n@interface IFSensedScoreEngine : NSObject\n+(id)defaultEngine;\n+(id)naive;\n+(id)sigmoid;\n+(id)power;\n@end\n\n","avg_line_length":26.2941176471,"max_line_length":85,"alphanum_fraction":0.7606263982} +{"size":402,"ext":"h","lang":"C","max_stars_count":null,"content":"\/\/\n\/\/ IMEmojiMessageBody.h\n\/\/ Pods\n\/\/\n\/\/ Created by \u6768\u78ca on 15\/7\/14.\n\/\/\n\/\/\n\n#import \"IMMessageBody.h\"\n\ntypedef NS_ENUM(NSInteger, EmojiContentType)\n{\n EmojiContent_IMG = 0,\n EmojiContent_GIF = 1,\n};\n\n@interface IMEmojiMessageBody : IMMessageBody\n@property (assign ,nonatomic) EmojiContentType type;\n@property (copy, nonatomic) NSString *content;\n@property (copy, nonatomic) NSString *name;\n@end\n","avg_line_length":18.2727272727,"max_line_length":52,"alphanum_fraction":0.7189054726} +{"size":339,"ext":"h","lang":"C","max_stars_count":1.0,"content":"\n\/*\n * Auto generated Run-Time-Environment Component Configuration File\n * *** Do not modify ! ***\n *\n * Project: 'temperature_pca10040' \n * Target: 'nrf52832_xxaa' \n *\/\n\n#ifndef RTE_COMPONENTS_H\n#define RTE_COMPONENTS_H\n\n\n\/*\n * Define the Device Header File: \n *\/\n#define CMSIS_device_header \"nrf.h\"\n\n\n#endif \/* RTE_COMPONENTS_H *\/\n","avg_line_length":16.1428571429,"max_line_length":67,"alphanum_fraction":0.6873156342} +{"size":31402,"ext":"h","lang":"C","max_stars_count":null,"content":"\/* A portable stdint.h\n ****************************************************************************\n * BSD License:\n ****************************************************************************\n *\n * Copyright (c) 2005-2016 Paul Hsieh\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n * 3. The name of the author may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\n * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n ****************************************************************************\n *\n * Version 0.1.16.0\n *\n * The ANSI C standard committee, for the C99 standard, specified the\n * inclusion of a new standard include file called stdint.h. This is\n * a very useful and long desired include file which contains several\n * very precise definitions for integer scalar types that is critically\n * important for making several classes of applications portable\n * including cryptography, hashing, variable length integer libraries\n * and so on. But for most developers its likely useful just for\n * programming sanity.\n *\n * The problem is that some compiler vendors chose to ignore the C99\n * standard and some older compilers have no opportunity to be updated.\n * Because of this situation, simply including stdint.h in your code\n * makes it unportable.\n *\n * So that's what this file is all about. It's an attempt to build a\n * single universal include file that works on as many platforms as\n * possible to deliver what stdint.h is supposed to. Even compilers\n * that already come with stdint.h can use this file instead without\n * any loss of functionality. A few things that should be noted about\n * this file:\n *\n * 1) It is not guaranteed to be portable and\/or present an identical\n * interface on all platforms. The extreme variability of the\n * ANSI C standard makes this an impossibility right from the\n * very get go. Its really only meant to be useful for the vast\n * majority of platforms that possess the capability of\n * implementing usefully and precisely defined, standard sized\n * integer scalars. Systems which are not intrinsically 2s\n * complement may produce invalid constants.\n *\n * 2) There is an unavoidable use of non-reserved symbols.\n *\n * 3) Other standard include files are invoked.\n *\n * 4) This file may come in conflict with future platforms that do\n * include stdint.h. The hope is that one or the other can be\n * used with no real difference.\n *\n * 5) In the current version, if your platform can't represent\n * int32_t, int16_t and int8_t, it just dumps out with a compiler\n * error.\n *\n * 6) 64 bit integers may or may not be defined. Test for their\n * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.\n * Note that this is different from the C99 specification which\n * requires the existence of 64 bit support in the compiler. If\n * this is not defined for your platform, yet it is capable of\n * dealing with 64 bits then it is because this file has not yet\n * been extended to cover all of your system's capabilities.\n *\n * 7) (u)intptr_t may or may not be defined. Test for its presence\n * with the test: #ifdef PTRDIFF_MAX. If this is not defined\n * for your platform, then it is because this file has not yet\n * been extended to cover all of your system's capabilities, not\n * because its optional.\n *\n * 8) The following might not been defined even if your platform is\n * capable of defining it:\n *\n * WCHAR_MIN\n * WCHAR_MAX\n * (u)int64_t\n * PTRDIFF_MIN\n * PTRDIFF_MAX\n * (u)intptr_t\n *\n * 9) The following have not been defined:\n *\n * WINT_MIN\n * WINT_MAX\n *\n * 10) The criteria for defining (u)int_least(*)_t isn't clear,\n * except for systems which don't have a type that precisely\n * defined 8, 16, or 32 bit types (which this include file does\n * not support anyways). Default definitions have been given.\n *\n * 11) The criteria for defining (u)int_fast(*)_t isn't something I\n * would trust to any particular compiler vendor or the ANSI C\n * committee. It is well known that \"compatible systems\" are\n * commonly created that have very different performance\n * characteristics from the systems they are compatible with,\n * especially those whose vendors make both the compiler and the\n * system. Default definitions have been given, but its strongly\n * recommended that users never use these definitions for any\n * reason (they do *NOT* deliver any serious guarantee of\n * improved performance -- not in this file, nor any vendor's\n * stdint.h).\n *\n * 12) The following macros:\n *\n * PRINTF_INTMAX_MODIFIER\n * PRINTF_INT64_MODIFIER\n * PRINTF_INT32_MODIFIER\n * PRINTF_INT16_MODIFIER\n * PRINTF_LEAST64_MODIFIER\n * PRINTF_LEAST32_MODIFIER\n * PRINTF_LEAST16_MODIFIER\n * PRINTF_INTPTR_MODIFIER\n *\n * are strings which have been defined as the modifiers required\n * for the \"d\", \"u\" and \"x\" printf formats to correctly output\n * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,\n * (u)least32_t, (u)least16_t and (u)intptr_t types respectively.\n * PRINTF_INTPTR_MODIFIER is not defined for some systems which\n * provide their own stdint.h. PRINTF_INT64_MODIFIER is not\n * defined if INT64_MAX is not defined. These are an extension\n * beyond what C99 specifies must be in stdint.h.\n *\n * In addition, the following macros are defined:\n *\n * PRINTF_INTMAX_HEX_WIDTH\n * PRINTF_INT64_HEX_WIDTH\n * PRINTF_INT32_HEX_WIDTH\n * PRINTF_INT16_HEX_WIDTH\n * PRINTF_INT8_HEX_WIDTH\n * PRINTF_INTMAX_DEC_WIDTH\n * PRINTF_INT64_DEC_WIDTH\n * PRINTF_INT32_DEC_WIDTH\n * PRINTF_INT16_DEC_WIDTH\n * PRINTF_UINT8_DEC_WIDTH\n * PRINTF_UINTMAX_DEC_WIDTH\n * PRINTF_UINT64_DEC_WIDTH\n * PRINTF_UINT32_DEC_WIDTH\n * PRINTF_UINT16_DEC_WIDTH\n * PRINTF_UINT8_DEC_WIDTH\n *\n * Which specifies the maximum number of characters required to\n * print the number of that type in either hexadecimal or decimal.\n * These are an extension beyond what C99 specifies must be in\n * stdint.h.\n *\n * Compilers tested (all with 0 warnings at their highest respective\n * settings): Borland Turbo C 2.0, WATCOM C\/C++ 11.0 (16 bits and 32\n * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio\n * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3\n *\n * This file should be considered a work in progress. Suggestions for\n * improvements, especially those which increase coverage are strongly\n * encouraged.\n *\n * Acknowledgements\n *\n * The following people have made significant contributions to the\n * development and testing of this file:\n *\n * Chris Howie\n * John Steele Scott\n * Dave Thorup\n * John Dill\n * Florian Wobbe\n * Christopher Sean Morrison\n * Mikkel Fahnoe Jorgensen\n *\n *\/\n\n#include \n#include \n#include \n\n\/*\n * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and\n * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.\n *\/\n\n#if ((defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600 && !defined(NTDDI_VERSION)) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)\n#include \n#define _PSTDINT_H_INCLUDED\n# if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__))\n# ifndef PRINTF_INT64_MODIFIER\n# define PRINTF_INT64_MODIFIER \"l\"\n# endif\n# ifndef PRINTF_INT32_MODIFIER\n# define PRINTF_INT32_MODIFIER \"\"\n# endif\n# else\n# ifndef PRINTF_INT64_MODIFIER\n# define PRINTF_INT64_MODIFIER \"ll\"\n# endif\n# ifndef PRINTF_INT32_MODIFIER\n# if (UINT_MAX == UINT32_MAX)\n# define PRINTF_INT32_MODIFIER \"\"\n# else\n# define PRINTF_INT32_MODIFIER \"l\"\n# endif\n# endif\n# endif\n# ifndef PRINTF_INT16_MODIFIER\n# define PRINTF_INT16_MODIFIER \"h\"\n# endif\n# ifndef PRINTF_INTMAX_MODIFIER\n# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER\n# endif\n# ifndef PRINTF_INT64_HEX_WIDTH\n# define PRINTF_INT64_HEX_WIDTH \"16\"\n# endif\n# ifndef PRINTF_UINT64_HEX_WIDTH\n# define PRINTF_UINT64_HEX_WIDTH \"16\"\n# endif\n# ifndef PRINTF_INT32_HEX_WIDTH\n# define PRINTF_INT32_HEX_WIDTH \"8\"\n# endif\n# ifndef PRINTF_UINT32_HEX_WIDTH\n# define PRINTF_UINT32_HEX_WIDTH \"8\"\n# endif\n# ifndef PRINTF_INT16_HEX_WIDTH\n# define PRINTF_INT16_HEX_WIDTH \"4\"\n# endif\n# ifndef PRINTF_UINT16_HEX_WIDTH\n# define PRINTF_UINT16_HEX_WIDTH \"4\"\n# endif\n# ifndef PRINTF_INT8_HEX_WIDTH\n# define PRINTF_INT8_HEX_WIDTH \"2\"\n# endif\n# ifndef PRINTF_UINT8_HEX_WIDTH\n# define PRINTF_UINT8_HEX_WIDTH \"2\"\n# endif\n# ifndef PRINTF_INT64_DEC_WIDTH\n# define PRINTF_INT64_DEC_WIDTH \"19\"\n# endif\n# ifndef PRINTF_UINT64_DEC_WIDTH\n# define PRINTF_UINT64_DEC_WIDTH \"20\"\n# endif\n# ifndef PRINTF_INT32_DEC_WIDTH\n# define PRINTF_INT32_DEC_WIDTH \"10\"\n# endif\n# ifndef PRINTF_UINT32_DEC_WIDTH\n# define PRINTF_UINT32_DEC_WIDTH \"10\"\n# endif\n# ifndef PRINTF_INT16_DEC_WIDTH\n# define PRINTF_INT16_DEC_WIDTH \"5\"\n# endif\n# ifndef PRINTF_UINT16_DEC_WIDTH\n# define PRINTF_UINT16_DEC_WIDTH \"5\"\n# endif\n# ifndef PRINTF_INT8_DEC_WIDTH\n# define PRINTF_INT8_DEC_WIDTH \"3\"\n# endif\n# ifndef PRINTF_UINT8_DEC_WIDTH\n# define PRINTF_UINT8_DEC_WIDTH \"3\"\n# endif\n# ifndef PRINTF_INTMAX_HEX_WIDTH\n# define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH\n# endif\n# ifndef PRINTF_UINTMAX_HEX_WIDTH\n# define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH\n# endif\n# ifndef PRINTF_INTMAX_DEC_WIDTH\n# define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH\n# endif\n# ifndef PRINTF_UINTMAX_DEC_WIDTH\n# define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH\n# endif\n\n\/*\n * Something really weird is going on with Open Watcom. Just pull some of\n * these duplicated definitions from Open Watcom's stdint.h file for now.\n *\/\n\n# if defined (__WATCOMC__) && __WATCOMC__ >= 1250\n# if !defined (INT64_C)\n# define INT64_C(x) (x + (INT64_MAX - INT64_MAX))\n# endif\n# if !defined (UINT64_C)\n# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))\n# endif\n# if !defined (INT32_C)\n# define INT32_C(x) (x + (INT32_MAX - INT32_MAX))\n# endif\n# if !defined (UINT32_C)\n# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))\n# endif\n# if !defined (INT16_C)\n# define INT16_C(x) (x)\n# endif\n# if !defined (UINT16_C)\n# define UINT16_C(x) (x)\n# endif\n# if !defined (INT8_C)\n# define INT8_C(x) (x)\n# endif\n# if !defined (UINT8_C)\n# define UINT8_C(x) (x)\n# endif\n# if !defined (UINT64_MAX)\n# define UINT64_MAX 18446744073709551615ULL\n# endif\n# if !defined (INT64_MAX)\n# define INT64_MAX 9223372036854775807LL\n# endif\n# if !defined (UINT32_MAX)\n# define UINT32_MAX 4294967295UL\n# endif\n# if !defined (INT32_MAX)\n# define INT32_MAX 2147483647L\n# endif\n# if !defined (INTMAX_MAX)\n# define INTMAX_MAX INT64_MAX\n# endif\n# if !defined (INTMAX_MIN)\n# define INTMAX_MIN INT64_MIN\n# endif\n# endif\n#endif\n\n\/*\n * I have no idea what is the truly correct thing to do on older Solaris.\n * From some online discussions, this seems to be what is being\n * recommended. For people who actually are developing on older Solaris,\n * what I would like to know is, does this define all of the relevant\n * macros of a complete stdint.h? Remember, in pstdint.h 64 bit is\n * considered optional.\n *\/\n\n#if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x420) && !defined(_PSTDINT_H_INCLUDED)\n#include \n#define _PSTDINT_H_INCLUDED\n#endif\n\n#ifndef _PSTDINT_H_INCLUDED\n#define _PSTDINT_H_INCLUDED\n\n#ifndef SIZE_MAX\n# define SIZE_MAX ((size_t)-1)\n#endif\n\n\/*\n * Deduce the type assignments from limits.h under the assumption that\n * integer sizes in bits are powers of 2, and follow the ANSI\n * definitions.\n *\/\n\n#ifndef UINT8_MAX\n# define UINT8_MAX 0xff\n#endif\n#if !defined(uint8_t) && !defined(_UINT8_T) && !defined(vxWorks)\n# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)\n typedef unsigned char uint8_t;\n# define UINT8_C(v) ((uint8_t) v)\n# else\n# error \"Platform not supported\"\n# endif\n#endif\n\n#ifndef INT8_MAX\n# define INT8_MAX 0x7f\n#endif\n#ifndef INT8_MIN\n# define INT8_MIN INT8_C(0x80)\n#endif\n#if !defined(int8_t) && !defined(_INT8_T) && !defined(vxWorks)\n# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)\n typedef signed char int8_t;\n# define INT8_C(v) ((int8_t) v)\n# else\n# error \"Platform not supported\"\n# endif\n#endif\n\n#ifndef UINT16_MAX\n# define UINT16_MAX 0xffff\n#endif\n#if !defined(uint16_t) && !defined(_UINT16_T) && !defined(vxWorks)\n#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)\n typedef unsigned int uint16_t;\n# ifndef PRINTF_INT16_MODIFIER\n# define PRINTF_INT16_MODIFIER \"\"\n# endif\n# define UINT16_C(v) ((uint16_t) (v))\n#elif (USHRT_MAX == UINT16_MAX)\n typedef unsigned short uint16_t;\n# define UINT16_C(v) ((uint16_t) (v))\n# ifndef PRINTF_INT16_MODIFIER\n# define PRINTF_INT16_MODIFIER \"h\"\n# endif\n#else\n#error \"Platform not supported\"\n#endif\n#endif\n\n#ifndef INT16_MAX\n# define INT16_MAX 0x7fff\n#endif\n#ifndef INT16_MIN\n# define INT16_MIN INT16_C(0x8000)\n#endif\n#if !defined(int16_t) && !defined(_INT16_T) && !defined(vxWorks)\n#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)\n typedef signed int int16_t;\n# define INT16_C(v) ((int16_t) (v))\n# ifndef PRINTF_INT16_MODIFIER\n# define PRINTF_INT16_MODIFIER \"\"\n# endif\n#elif (SHRT_MAX == INT16_MAX)\n typedef signed short int16_t;\n# define INT16_C(v) ((int16_t) (v))\n# ifndef PRINTF_INT16_MODIFIER\n# define PRINTF_INT16_MODIFIER \"h\"\n# endif\n#else\n#error \"Platform not supported\"\n#endif\n#endif\n\n#ifndef UINT32_MAX\n# define UINT32_MAX (0xffffffffUL)\n#endif\n#if !defined(uint32_t) && !defined(_UINT32_T) && !defined(vxWorks)\n#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)\n typedef unsigned long uint32_t;\n# define UINT32_C(v) v ## UL\n# ifndef PRINTF_INT32_MODIFIER\n# define PRINTF_INT32_MODIFIER \"l\"\n# endif\n#elif (UINT_MAX == UINT32_MAX)\n typedef unsigned int uint32_t;\n# ifndef PRINTF_INT32_MODIFIER\n# define PRINTF_INT32_MODIFIER \"\"\n# endif\n# define UINT32_C(v) v ## U\n#elif (USHRT_MAX == UINT32_MAX)\n typedef unsigned short uint32_t;\n# define UINT32_C(v) ((unsigned short) (v))\n# ifndef PRINTF_INT32_MODIFIER\n# define PRINTF_INT32_MODIFIER \"\"\n# endif\n#else\n#error \"Platform not supported\"\n#endif\n#endif\n\n#ifndef INT32_MAX\n# define INT32_MAX (0x7fffffffL)\n#endif\n#ifndef INT32_MIN\n# define INT32_MIN INT32_C(0x80000000)\n#endif\n#if !defined(int32_t) && !defined(_INT32_T) && !defined(vxWorks)\n#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)\n typedef signed long int32_t;\n# define INT32_C(v) v ## L\n# ifndef PRINTF_INT32_MODIFIER\n# define PRINTF_INT32_MODIFIER \"l\"\n# endif\n#elif (INT_MAX == INT32_MAX)\n typedef signed int int32_t;\n# define INT32_C(v) v\n# ifndef PRINTF_INT32_MODIFIER\n# define PRINTF_INT32_MODIFIER \"\"\n# endif\n#elif (SHRT_MAX == INT32_MAX)\n typedef signed short int32_t;\n# define INT32_C(v) ((short) (v))\n# ifndef PRINTF_INT32_MODIFIER\n# define PRINTF_INT32_MODIFIER \"\"\n# endif\n#else\n#error \"Platform not supported\"\n#endif\n#endif\n\n\/*\n * The macro stdint_int64_defined is temporarily used to record\n * whether or not 64 integer support is available. It must be\n * defined for any 64 integer extensions for new platforms that are\n * added.\n *\/\n\n#undef stdint_int64_defined\n#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)\n# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)\n# define stdint_int64_defined\n typedef long long int64_t;\n typedef unsigned long long uint64_t;\n# define UINT64_C(v) v ## ULL\n# define INT64_C(v) v ## LL\n# ifndef PRINTF_INT64_MODIFIER\n# define PRINTF_INT64_MODIFIER \"ll\"\n# endif\n# endif\n#endif\n\n#if !defined (stdint_int64_defined)\n# if defined(__GNUC__) && !defined(vxWorks)\n# define stdint_int64_defined\n __extension__ typedef long long int64_t;\n __extension__ typedef unsigned long long uint64_t;\n# define UINT64_C(v) v ## ULL\n# define INT64_C(v) v ## LL\n# ifndef PRINTF_INT64_MODIFIER\n# define PRINTF_INT64_MODIFIER \"ll\"\n# endif\n# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)\n# define stdint_int64_defined\n typedef long long int64_t;\n typedef unsigned long long uint64_t;\n# define UINT64_C(v) v ## ULL\n# define INT64_C(v) v ## LL\n# ifndef PRINTF_INT64_MODIFIER\n# define PRINTF_INT64_MODIFIER \"ll\"\n# endif\n# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)\n# define stdint_int64_defined\n typedef __int64 int64_t;\n typedef unsigned __int64 uint64_t;\n# define UINT64_C(v) v ## UI64\n# define INT64_C(v) v ## I64\n# ifndef PRINTF_INT64_MODIFIER\n# define PRINTF_INT64_MODIFIER \"I64\"\n# endif\n# endif\n#endif\n\n#if !defined (LONG_LONG_MAX) && defined (INT64_C)\n# define LONG_LONG_MAX INT64_C (9223372036854775807)\n#endif\n#ifndef ULONG_LONG_MAX\n# define ULONG_LONG_MAX UINT64_C (18446744073709551615)\n#endif\n\n#if !defined (INT64_MAX) && defined (INT64_C)\n# define INT64_MAX INT64_C (9223372036854775807)\n#endif\n#if !defined (INT64_MIN) && defined (INT64_C)\n# define INT64_MIN INT64_C (-9223372036854775808)\n#endif\n#if !defined (UINT64_MAX) && defined (INT64_C)\n# define UINT64_MAX UINT64_C (18446744073709551615)\n#endif\n\n\/*\n * Width of hexadecimal for number field.\n *\/\n\n#ifndef PRINTF_INT64_HEX_WIDTH\n# define PRINTF_INT64_HEX_WIDTH \"16\"\n#endif\n#ifndef PRINTF_INT32_HEX_WIDTH\n# define PRINTF_INT32_HEX_WIDTH \"8\"\n#endif\n#ifndef PRINTF_INT16_HEX_WIDTH\n# define PRINTF_INT16_HEX_WIDTH \"4\"\n#endif\n#ifndef PRINTF_INT8_HEX_WIDTH\n# define PRINTF_INT8_HEX_WIDTH \"2\"\n#endif\n#ifndef PRINTF_INT64_DEC_WIDTH\n# define PRINTF_INT64_DEC_WIDTH \"19\"\n#endif\n#ifndef PRINTF_INT32_DEC_WIDTH\n# define PRINTF_INT32_DEC_WIDTH \"10\"\n#endif\n#ifndef PRINTF_INT16_DEC_WIDTH\n# define PRINTF_INT16_DEC_WIDTH \"5\"\n#endif\n#ifndef PRINTF_INT8_DEC_WIDTH\n# define PRINTF_INT8_DEC_WIDTH \"3\"\n#endif\n#ifndef PRINTF_UINT64_DEC_WIDTH\n# define PRINTF_UINT64_DEC_WIDTH \"20\"\n#endif\n#ifndef PRINTF_UINT32_DEC_WIDTH\n# define PRINTF_UINT32_DEC_WIDTH \"10\"\n#endif\n#ifndef PRINTF_UINT16_DEC_WIDTH\n# define PRINTF_UINT16_DEC_WIDTH \"5\"\n#endif\n#ifndef PRINTF_UINT8_DEC_WIDTH\n# define PRINTF_UINT8_DEC_WIDTH \"3\"\n#endif\n\n\/*\n * Ok, lets not worry about 128 bit integers for now. Moore's law says\n * we don't need to worry about that until about 2040 at which point\n * we'll have bigger things to worry about.\n *\/\n\n#ifdef stdint_int64_defined\n typedef int64_t intmax_t;\n typedef uint64_t uintmax_t;\n# define INTMAX_MAX INT64_MAX\n# define INTMAX_MIN INT64_MIN\n# define UINTMAX_MAX UINT64_MAX\n# define UINTMAX_C(v) UINT64_C(v)\n# define INTMAX_C(v) INT64_C(v)\n# ifndef PRINTF_INTMAX_MODIFIER\n# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER\n# endif\n# ifndef PRINTF_INTMAX_HEX_WIDTH\n# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH\n# endif\n# ifndef PRINTF_INTMAX_DEC_WIDTH\n# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH\n# endif\n#else\n typedef int32_t intmax_t;\n typedef uint32_t uintmax_t;\n# define INTMAX_MAX INT32_MAX\n# define UINTMAX_MAX UINT32_MAX\n# define UINTMAX_C(v) UINT32_C(v)\n# define INTMAX_C(v) INT32_C(v)\n# ifndef PRINTF_INTMAX_MODIFIER\n# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER\n# endif\n# ifndef PRINTF_INTMAX_HEX_WIDTH\n# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH\n# endif\n# ifndef PRINTF_INTMAX_DEC_WIDTH\n# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH\n# endif\n#endif\n\n\/*\n * Because this file currently only supports platforms which have\n * precise powers of 2 as bit sizes for the default integers, the\n * least definitions are all trivial. Its possible that a future\n * version of this file could have different definitions.\n *\/\n\n#ifndef stdint_least_defined\n typedef int8_t int_least8_t;\n typedef uint8_t uint_least8_t;\n typedef int16_t int_least16_t;\n typedef uint16_t uint_least16_t;\n typedef int32_t int_least32_t;\n typedef uint32_t uint_least32_t;\n# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER\n# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER\n# define UINT_LEAST8_MAX UINT8_MAX\n# define INT_LEAST8_MAX INT8_MAX\n# define UINT_LEAST16_MAX UINT16_MAX\n# define INT_LEAST16_MAX INT16_MAX\n# define UINT_LEAST32_MAX UINT32_MAX\n# define INT_LEAST32_MAX INT32_MAX\n# define INT_LEAST8_MIN INT8_MIN\n# define INT_LEAST16_MIN INT16_MIN\n# define INT_LEAST32_MIN INT32_MIN\n# ifdef stdint_int64_defined\n typedef int64_t int_least64_t;\n typedef uint64_t uint_least64_t;\n# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER\n# define UINT_LEAST64_MAX UINT64_MAX\n# define INT_LEAST64_MAX INT64_MAX\n# define INT_LEAST64_MIN INT64_MIN\n# endif\n#endif\n#undef stdint_least_defined\n\n\/*\n * The ANSI C committee has defined *int*_fast*_t types as well. This,\n * of course, defies rationality -- you can't know what will be fast\n * just from the type itself. Even for a given architecture, compatible\n * implementations might have different performance characteristics.\n * Developers are warned to stay away from these types when using this\n * or any other stdint.h.\n *\/\n\ntypedef int_least8_t int_fast8_t;\ntypedef uint_least8_t uint_fast8_t;\ntypedef int_least16_t int_fast16_t;\ntypedef uint_least16_t uint_fast16_t;\ntypedef int_least32_t int_fast32_t;\ntypedef uint_least32_t uint_fast32_t;\n#define UINT_FAST8_MAX UINT_LEAST8_MAX\n#define INT_FAST8_MAX INT_LEAST8_MAX\n#define UINT_FAST16_MAX UINT_LEAST16_MAX\n#define INT_FAST16_MAX INT_LEAST16_MAX\n#define UINT_FAST32_MAX UINT_LEAST32_MAX\n#define INT_FAST32_MAX INT_LEAST32_MAX\n#define INT_FAST8_MIN INT_LEAST8_MIN\n#define INT_FAST16_MIN INT_LEAST16_MIN\n#define INT_FAST32_MIN INT_LEAST32_MIN\n#ifdef stdint_int64_defined\n typedef int_least64_t int_fast64_t;\n typedef uint_least64_t uint_fast64_t;\n# define UINT_FAST64_MAX UINT_LEAST64_MAX\n# define INT_FAST64_MAX INT_LEAST64_MAX\n# define INT_FAST64_MIN INT_LEAST64_MIN\n#endif\n\n#undef stdint_int64_defined\n\n\/*\n * Whatever piecemeal, per compiler thing we can do about the wchar_t\n * type limits.\n *\/\n\n#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks)\n# include \n# ifndef WCHAR_MIN\n# define WCHAR_MIN 0\n# endif\n# ifndef WCHAR_MAX\n# define WCHAR_MAX ((wchar_t)-1)\n# endif\n#endif\n\n\/*\n * Whatever piecemeal, per compiler\/platform thing we can do about the\n * (u)intptr_t types and limits.\n *\/\n\n#if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T)\n# define STDINT_H_UINTPTR_T_DEFINED\n#endif\n\n#ifndef STDINT_H_UINTPTR_T_DEFINED\n# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__)\n# define stdint_intptr_bits 64\n# elif defined (__WATCOMC__) || defined (__TURBOC__)\n# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)\n# define stdint_intptr_bits 16\n# else\n# define stdint_intptr_bits 32\n# endif\n# elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__)\n# define stdint_intptr_bits 32\n# elif defined (__INTEL_COMPILER)\n\/* TODO -- what did Intel do about x86-64? *\/\n# else\n\/* #error \"This platform might not be supported yet\" *\/\n# endif\n\n# ifdef stdint_intptr_bits\n# define stdint_intptr_glue3_i(a,b,c) a##b##c\n# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)\n# ifndef PRINTF_INTPTR_MODIFIER\n# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)\n# endif\n# ifndef PTRDIFF_MAX\n# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)\n# endif\n# ifndef PTRDIFF_MIN\n# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)\n# endif\n# ifndef UINTPTR_MAX\n# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)\n# endif\n# ifndef INTPTR_MAX\n# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)\n# endif\n# ifndef INTPTR_MIN\n# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)\n# endif\n# ifndef INTPTR_C\n# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)\n# endif\n# ifndef UINTPTR_C\n# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)\n# endif\n typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;\n typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;\n# else\n\/* TODO -- This following is likely wrong for some platforms, and does\n nothing for the definition of uintptr_t. *\/\n typedef ptrdiff_t intptr_t;\n# endif\n# define STDINT_H_UINTPTR_T_DEFINED\n#endif\n\n\/*\n * Assumes sig_atomic_t is signed and we have a 2s complement machine.\n *\/\n\n#ifndef SIG_ATOMIC_MAX\n# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)\n#endif\n\n#endif\n\n#if defined (__TEST_PSTDINT_FOR_CORRECTNESS)\n\n\/*\n * Please compile with the maximum warning settings to make sure macros are\n * not defined more than once.\n *\/\n\n#include \n#include \n#include \n\n#define glue3_aux(x,y,z) x ## y ## z\n#define glue3(x,y,z) glue3_aux(x,y,z)\n\n#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0);\n#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0);\n\n#define DECL(us,bits) glue3(DECL,us,) (bits)\n\n#define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf (\"Something wrong with UINT%d_MAX\\n\", bits)\n\n#define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; }\n\n#define X_SIZE_MAX ((size_t)-1)\n\nint main () {\n int err_n = 0;\n int err_first = 0;\n DECL(I,8)\n DECL(U,8)\n DECL(I,16)\n DECL(U,16)\n DECL(I,32)\n DECL(U,32)\n#ifdef INT64_MAX\n DECL(I,64)\n DECL(U,64)\n#endif\n intmax_t imax = INTMAX_C(0);\n uintmax_t umax = UINTMAX_C(0);\n char str0[256], str1[256];\n\n sprintf (str0, \"%\" PRINTF_INT32_MODIFIER \"d\", INT32_C(2147483647));\n if (0 != strcmp (str0, \"2147483647\")) REPORTERROR ((\"Something wrong with PRINTF_INT32_MODIFIER : %s\\n\", str0));\n if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR ((\"Something wrong with PRINTF_INT32_DEC_WIDTH : %s\\n\", PRINTF_INT32_DEC_WIDTH));\n sprintf (str0, \"%\" PRINTF_INT32_MODIFIER \"u\", UINT32_C(4294967295));\n if (0 != strcmp (str0, \"4294967295\")) REPORTERROR ((\"Something wrong with PRINTF_INT32_MODIFIER : %s\\n\", str0));\n if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR ((\"Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\\n\", PRINTF_UINT32_DEC_WIDTH));\n#ifdef INT64_MAX\n sprintf (str1, \"%\" PRINTF_INT64_MODIFIER \"d\", INT64_C(9223372036854775807));\n if (0 != strcmp (str1, \"9223372036854775807\")) REPORTERROR ((\"Something wrong with PRINTF_INT32_MODIFIER : %s\\n\", str1));\n if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR ((\"Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\\n\", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1)));\n sprintf (str1, \"%\" PRINTF_INT64_MODIFIER \"u\", UINT64_C(18446744073709550591));\n if (0 != strcmp (str1, \"18446744073709550591\")) REPORTERROR ((\"Something wrong with PRINTF_INT32_MODIFIER : %s\\n\", str1));\n if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR ((\"Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\\n\", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1)));\n#endif\n\n sprintf (str0, \"%d %x\\n\", 0, ~0);\n\n sprintf (str1, \"%d %x\\n\", i8, ~0);\n if (0 != strcmp (str0, str1)) REPORTERROR ((\"Something wrong with i8 : %s\\n\", str1));\n sprintf (str1, \"%u %x\\n\", u8, ~0);\n if (0 != strcmp (str0, str1)) REPORTERROR ((\"Something wrong with u8 : %s\\n\", str1));\n sprintf (str1, \"%d %x\\n\", i16, ~0);\n if (0 != strcmp (str0, str1)) REPORTERROR ((\"Something wrong with i16 : %s\\n\", str1));\n sprintf (str1, \"%u %x\\n\", u16, ~0);\n if (0 != strcmp (str0, str1)) REPORTERROR ((\"Something wrong with u16 : %s\\n\", str1));\n sprintf (str1, \"%\" PRINTF_INT32_MODIFIER \"d %x\\n\", i32, ~0);\n if (0 != strcmp (str0, str1)) REPORTERROR ((\"Something wrong with i32 : %s\\n\", str1));\n sprintf (str1, \"%\" PRINTF_INT32_MODIFIER \"u %x\\n\", u32, ~0);\n if (0 != strcmp (str0, str1)) REPORTERROR ((\"Something wrong with u32 : %s\\n\", str1));\n#ifdef INT64_MAX\n sprintf (str1, \"%\" PRINTF_INT64_MODIFIER \"d %x\\n\", i64, ~0);\n if (0 != strcmp (str0, str1)) REPORTERROR ((\"Something wrong with i64 : %s\\n\", str1));\n#endif\n sprintf (str1, \"%\" PRINTF_INTMAX_MODIFIER \"d %x\\n\", imax, ~0);\n if (0 != strcmp (str0, str1)) REPORTERROR ((\"Something wrong with imax : %s\\n\", str1));\n sprintf (str1, \"%\" PRINTF_INTMAX_MODIFIER \"u %x\\n\", umax, ~0);\n if (0 != strcmp (str0, str1)) REPORTERROR ((\"Something wrong with umax : %s\\n\", str1));\n\n TESTUMAX(8);\n TESTUMAX(16);\n TESTUMAX(32);\n#ifdef INT64_MAX\n TESTUMAX(64);\n#endif\n\n#define STR(v) #v\n#define Q(v) printf (\"sizeof \" STR(v) \" = %u\\n\", (unsigned) sizeof (v));\n if (err_n) {\n printf (\"pstdint.h is not correct. Please use sizes below to correct it:\\n\");\n }\n\n Q(int)\n Q(unsigned)\n Q(long int)\n Q(short int)\n Q(int8_t)\n Q(int16_t)\n Q(int32_t)\n#ifdef INT64_MAX\n Q(int64_t)\n#endif\n\n#if UINT_MAX < X_SIZE_MAX\n printf (\"UINT_MAX < X_SIZE_MAX\\n\");\n#else\n printf (\"UINT_MAX >= X_SIZE_MAX\\n\");\n#endif\n printf (\"%\" PRINTF_INT64_MODIFIER \"u vs %\" PRINTF_INT64_MODIFIER \"u\\n\", UINT_MAX, X_SIZE_MAX);\n\n return EXIT_SUCCESS;\n}\n\n#endif\n","avg_line_length":34.1326086957,"max_line_length":454,"alphanum_fraction":0.7198904528} +{"size":69527,"ext":"h","lang":"C","max_stars_count":null,"content":"\/* stb_image_write - v1.15 - public domain - http:\/\/nothings.org\/stb\n writes out PNG\/BMP\/TGA\/JPEG\/HDR images to C stdio - Sean Barrett 2010-2015\n no warranty implied; use at your own risk\n Before #including,\n #define STB_IMAGE_WRITE_IMPLEMENTATION\n in the file that you want to have the implementation.\n Will probably not work correctly with strict-aliasing optimizations.\nABOUT:\n This header file is a library for writing images to C stdio or a callback.\n The PNG output is not optimal; it is 20-50% larger than the file\n written by a decent optimizing implementation; though providing a custom\n zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that.\n This library is designed for source code compactness and simplicity,\n not optimal image file size or run-time performance.\nBUILDING:\n You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h.\n You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace\n malloc,realloc,free.\n You can #define STBIW_MEMMOVE() to replace memmove()\n You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function\n for PNG compression (instead of the builtin one), it must have the following signature:\n unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality);\n The returned data will be freed with STBIW_FREE() (free() by default),\n so it must be heap allocated with STBIW_MALLOC() (malloc() by default),\nUNICODE:\n If compiling for Windows and you wish to use Unicode filenames, compile\n with\n #define STBIW_WINDOWS_UTF8\n and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert\n Windows wchar_t filenames to utf8.\nUSAGE:\n There are five functions, one for each image file format:\n int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes);\n int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data);\n int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data);\n int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality);\n int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);\n void stbi_flip_vertically_on_write(int flag); \/\/ flag is non-zero to flip data vertically\n There are also five equivalent functions that use an arbitrary write function. You are\n expected to open\/close your file-equivalent before and after calling these:\n int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes);\n int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data);\n int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data);\n int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data);\n int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality);\n where the callback is:\n void stbi_write_func(void *context, void *data, int size);\n You can configure it with these global variables:\n int stbi_write_tga_with_rle; \/\/ defaults to true; set to 0 to disable RLE\n int stbi_write_png_compression_level; \/\/ defaults to 8; set to higher for more compression\n int stbi_write_force_png_filter; \/\/ defaults to -1; set to 0..5 to force a filter mode\n You can define STBI_WRITE_NO_STDIO to disable the file variant of these\n functions, so the library will not use stdio.h at all. However, this will\n also disable HDR writing, because it requires stdio for formatted output.\n Each function returns 0 on failure and non-0 on success.\n The functions create an image file defined by the parameters. The image\n is a rectangle of pixels stored from left-to-right, top-to-bottom.\n Each pixel contains 'comp' channels of data stored interleaved with 8-bits\n per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is\n monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall.\n The *data pointer points to the first byte of the top-left-most pixel.\n For PNG, \"stride_in_bytes\" is the distance in bytes from the first byte of\n a row of pixels to the first byte of the next row of pixels.\n PNG creates output files with the same number of components as the input.\n The BMP format expands Y to RGB in the file format and does not\n output alpha.\n PNG supports writing rectangles of data even when the bytes storing rows of\n data are not consecutive in memory (e.g. sub-rectangles of a larger image),\n by supplying the stride between the beginning of adjacent rows. The other\n formats do not. (Thus you cannot write a native-format BMP through the BMP\n writer, both because it is in BGR order and because it may have padding\n at the end of the line.)\n PNG allows you to set the deflate compression level by setting the global\n variable 'stbi_write_png_compression_level' (it defaults to 8).\n HDR expects linear float data. Since the format is always 32-bit rgb(e)\n data, alpha (if provided) is discarded, and for monochrome data it is\n replicated across all three channels.\n TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed\n data, set the global variable 'stbi_write_tga_with_rle' to 0.\n JPEG does ignore alpha channels in input data; quality is between 1 and 100.\n Higher quality looks better but results in a bigger image.\n JPEG baseline (no JPEG progressive).\nCREDITS:\n Sean Barrett - PNG\/BMP\/TGA\n Baldur Karlsson - HDR\n Jean-Sebastien Guay - TGA monochrome\n Tim Kelsey - misc enhancements\n Alan Hickman - TGA RLE\n Emmanuel Julien - initial file IO callback implementation\n Jon Olick - original jo_jpeg.cpp code\n Daniel Gibson - integrate JPEG, allow external zlib\n Aarni Koskela - allow choosing PNG filter\n bugfixes:\n github:Chribba\n Guillaume Chereau\n github:jry2\n github:romigrou\n Sergio Gonzalez\n Jonas Karlsson\n Filip Wasil\n Thatcher Ulrich\n github:poppolopoppo\n Patrick Boettcher\n github:xeekworx\n Cap Petschulat\n Simon Rodriguez\n Ivan Tikhonov\n github:ignotion\n Adam Schackart\nLICENSE\n See end of file for license information.\n*\/\n\n#ifndef INCLUDE_STB_IMAGE_WRITE_H\n#define INCLUDE_STB_IMAGE_WRITE_H\n\n#include \n\n\/\/ if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline'\n#ifndef STBIWDEF\n#ifdef STB_IMAGE_WRITE_STATIC\n#define STBIWDEF static\n#else\n#ifdef __cplusplus\n#define STBIWDEF extern \"C\"\n#else\n#define STBIWDEF extern\n#endif\n#endif\n#endif\n\n#ifndef STB_IMAGE_WRITE_STATIC \/\/ C++ forbids static forward declarations\nextern int stbi_write_tga_with_rle;\nextern int stbi_write_png_compression_level;\nextern int stbi_write_force_png_filter;\n#endif\n\n#ifndef STBI_WRITE_NO_STDIO\nSTBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes);\nSTBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data);\nSTBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data);\nSTBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);\nSTBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality);\n\n#ifdef STBI_WINDOWS_UTF8\nSTBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input);\n#endif\n#endif\n\ntypedef void stbi_write_func(void *context, void *data, int size);\n\nSTBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes);\nSTBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data);\nSTBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data);\nSTBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data);\nSTBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality);\n\nSTBIWDEF void stbi_flip_vertically_on_write(int flip_boolean);\n\n#endif\/\/INCLUDE_STB_IMAGE_WRITE_H\n\n#ifdef STB_IMAGE_WRITE_IMPLEMENTATION\n\n#ifdef _WIN32\n #ifndef _CRT_SECURE_NO_WARNINGS\n #define _CRT_SECURE_NO_WARNINGS\n #endif\n #ifndef _CRT_NONSTDC_NO_DEPRECATE\n #define _CRT_NONSTDC_NO_DEPRECATE\n #endif\n#endif\n\n#ifndef STBI_WRITE_NO_STDIO\n#include \n#endif \/\/ STBI_WRITE_NO_STDIO\n\n#include \n#include \n#include \n#include \n\n#if defined(STBIW_MALLOC) && defined(STBIW_FREE) && (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED))\n\/\/ ok\n#elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && !defined(STBIW_REALLOC_SIZED)\n\/\/ ok\n#else\n#error \"Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED).\"\n#endif\n\n#ifndef STBIW_MALLOC\n#define STBIW_MALLOC(sz) malloc(sz)\n#define STBIW_REALLOC(p,newsz) realloc(p,newsz)\n#define STBIW_FREE(p) free(p)\n#endif\n\n#ifndef STBIW_REALLOC_SIZED\n#define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz)\n#endif\n\n\n#ifndef STBIW_MEMMOVE\n#define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz)\n#endif\n\n\n#ifndef STBIW_ASSERT\n#include \n#define STBIW_ASSERT(x) assert(x)\n#endif\n\n#define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff)\n\n#ifdef STB_IMAGE_WRITE_STATIC\nstatic int stbi_write_png_compression_level = 8;\nstatic int stbi_write_tga_with_rle = 1;\nstatic int stbi_write_force_png_filter = -1;\n#else\nint stbi_write_png_compression_level = 8;\nint stbi_write_tga_with_rle = 1;\nint stbi_write_force_png_filter = -1;\n#endif\n\nstatic int stbi__flip_vertically_on_write = 0;\n\nSTBIWDEF void stbi_flip_vertically_on_write(int flag)\n{\n stbi__flip_vertically_on_write = flag;\n}\n\ntypedef struct\n{\n stbi_write_func *func;\n void *context;\n unsigned char buffer[64];\n int buf_used;\n} stbi__write_context;\n\n\/\/ initialize a callback-based context\nstatic void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context)\n{\n s->func = c;\n s->context = context;\n}\n\n#ifndef STBI_WRITE_NO_STDIO\n\nstatic void stbi__stdio_write(void *context, void *data, int size)\n{\n fwrite(data,1,size,(FILE*) context);\n}\n\n#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)\n#ifdef __cplusplus\n#define STBIW_EXTERN extern \"C\"\n#else\n#define STBIW_EXTERN extern\n#endif\nSTBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide);\nSTBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);\n\nSTBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)\n{\n\treturn WideCharToMultiByte(65001 \/* UTF8 *\/, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);\n}\n#endif\n\nstatic FILE *stbiw__fopen(char const *filename, char const *mode)\n{\n FILE *f;\n#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)\n wchar_t wMode[64];\n wchar_t wFilename[1024];\n\tif (0 == MultiByteToWideChar(65001 \/* UTF8 *\/, 0, filename, -1, wFilename, sizeof(wFilename)))\n return 0;\n\n\tif (0 == MultiByteToWideChar(65001 \/* UTF8 *\/, 0, mode, -1, wMode, sizeof(wMode)))\n return 0;\n\n#if _MSC_VER >= 1400\n\tif (0 != _wfopen_s(&f, wFilename, wMode))\n\t\tf = 0;\n#else\n f = _wfopen(wFilename, wMode);\n#endif\n\n#elif defined(_MSC_VER) && _MSC_VER >= 1400\n if (0 != fopen_s(&f, filename, mode))\n f=0;\n#else\n f = fopen(filename, mode);\n#endif\n return f;\n}\n\nstatic int stbi__start_write_file(stbi__write_context *s, const char *filename)\n{\n FILE *f = stbiw__fopen(filename, \"wb\");\n stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f);\n return f != NULL;\n}\n\nstatic void stbi__end_write_file(stbi__write_context *s)\n{\n fclose((FILE *)s->context);\n}\n\n#endif \/\/ !STBI_WRITE_NO_STDIO\n\ntypedef unsigned int stbiw_uint32;\ntypedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1];\n\nstatic void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v)\n{\n while (*fmt) {\n switch (*fmt++) {\n case ' ': break;\n case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int));\n s->func(s->context,&x,1);\n break; }\n case '2': { int x = va_arg(v,int);\n unsigned char b[2];\n b[0] = STBIW_UCHAR(x);\n b[1] = STBIW_UCHAR(x>>8);\n s->func(s->context,b,2);\n break; }\n case '4': { stbiw_uint32 x = va_arg(v,int);\n unsigned char b[4];\n b[0]=STBIW_UCHAR(x);\n b[1]=STBIW_UCHAR(x>>8);\n b[2]=STBIW_UCHAR(x>>16);\n b[3]=STBIW_UCHAR(x>>24);\n s->func(s->context,b,4);\n break; }\n default:\n STBIW_ASSERT(0);\n return;\n }\n }\n}\n\nstatic void stbiw__writef(stbi__write_context *s, const char *fmt, ...)\n{\n va_list v;\n va_start(v, fmt);\n stbiw__writefv(s, fmt, v);\n va_end(v);\n}\n\nstatic void stbiw__write_flush(stbi__write_context *s)\n{\n if (s->buf_used) {\n s->func(s->context, &s->buffer, s->buf_used);\n s->buf_used = 0;\n }\n}\n\nstatic void stbiw__putc(stbi__write_context *s, unsigned char c)\n{\n s->func(s->context, &c, 1);\n}\n\nstatic void stbiw__write1(stbi__write_context *s, unsigned char a)\n{\n if (s->buf_used + 1 > sizeof(s->buffer))\n stbiw__write_flush(s);\n s->buffer[s->buf_used++] = a;\n}\n\nstatic void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c)\n{\n int n;\n if (s->buf_used + 3 > sizeof(s->buffer))\n stbiw__write_flush(s);\n n = s->buf_used;\n s->buf_used = n+3;\n s->buffer[n+0] = a;\n s->buffer[n+1] = b;\n s->buffer[n+2] = c;\n}\n\nstatic void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d)\n{\n unsigned char bg[3] = { 255, 0, 255}, px[3];\n int k;\n\n if (write_alpha < 0)\n stbiw__write1(s, d[comp - 1]);\n\n switch (comp) {\n case 2: \/\/ 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case\n case 1:\n if (expand_mono)\n stbiw__write3(s, d[0], d[0], d[0]); \/\/ monochrome bmp\n else\n stbiw__write1(s, d[0]); \/\/ monochrome TGA\n break;\n case 4:\n if (!write_alpha) {\n \/\/ composite against pink background\n for (k = 0; k < 3; ++k)\n px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) \/ 255;\n stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]);\n break;\n }\n \/* FALLTHROUGH *\/\n case 3:\n stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]);\n break;\n }\n if (write_alpha > 0)\n stbiw__write1(s, d[comp - 1]);\n}\n\nstatic void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono)\n{\n stbiw_uint32 zero = 0;\n int i,j, j_end;\n\n if (y <= 0)\n return;\n\n if (stbi__flip_vertically_on_write)\n vdir *= -1;\n\n if (vdir < 0) {\n j_end = -1; j = y-1;\n } else {\n j_end = y; j = 0;\n }\n\n for (; j != j_end; j += vdir) {\n for (i=0; i < x; ++i) {\n unsigned char *d = (unsigned char *) data + (j*x+i)*comp;\n stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d);\n }\n stbiw__write_flush(s);\n s->func(s->context, &zero, scanline_pad);\n }\n}\n\nstatic int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...)\n{\n if (y < 0 || x < 0) {\n return 0;\n } else {\n va_list v;\n va_start(v, fmt);\n stbiw__writefv(s, fmt, v);\n va_end(v);\n stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono);\n return 1;\n }\n}\n\nstatic int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data)\n{\n int pad = (-x*3) & 3;\n return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad,\n \"11 4 22 4\" \"4 44 22 444444\",\n 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, \/\/ file header\n 40, x,y, 1,24, 0,0,0,0,0,0); \/\/ bitmap header\n}\n\nSTBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)\n{\n stbi__write_context s = { 0 };\n stbi__start_write_callbacks(&s, func, context);\n return stbi_write_bmp_core(&s, x, y, comp, data);\n}\n\n#ifndef STBI_WRITE_NO_STDIO\nSTBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data)\n{\n stbi__write_context s = { 0 };\n if (stbi__start_write_file(&s,filename)) {\n int r = stbi_write_bmp_core(&s, x, y, comp, data);\n stbi__end_write_file(&s);\n return r;\n } else\n return 0;\n}\n#endif \/\/!STBI_WRITE_NO_STDIO\n\nstatic int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data)\n{\n int has_alpha = (comp == 2 || comp == 4);\n int colorbytes = has_alpha ? comp-1 : comp;\n int format = colorbytes < 2 ? 3 : 2; \/\/ 3 color channels (RGB\/RGBA) = 2, 1 color channel (Y\/YA) = 3\n\n if (y < 0 || x < 0)\n return 0;\n\n if (!stbi_write_tga_with_rle) {\n return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0,\n \"111 221 2222 11\", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8);\n } else {\n int i,j,k;\n int jend, jdir;\n\n stbiw__writef(s, \"111 221 2222 11\", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8);\n\n if (stbi__flip_vertically_on_write) {\n j = 0;\n jend = y;\n jdir = 1;\n } else {\n j = y-1;\n jend = -1;\n jdir = -1;\n }\n for (; j != jend; j += jdir) {\n unsigned char *row = (unsigned char *) data + j * x * comp;\n int len;\n\n for (i = 0; i < x; i += len) {\n unsigned char *begin = row + i * comp;\n int diff = 1;\n len = 1;\n\n if (i < x - 1) {\n ++len;\n diff = memcmp(begin, row + (i + 1) * comp, comp);\n if (diff) {\n const unsigned char *prev = begin;\n for (k = i + 2; k < x && len < 128; ++k) {\n if (memcmp(prev, row + k * comp, comp)) {\n prev += comp;\n ++len;\n } else {\n --len;\n break;\n }\n }\n } else {\n for (k = i + 2; k < x && len < 128; ++k) {\n if (!memcmp(begin, row + k * comp, comp)) {\n ++len;\n } else {\n break;\n }\n }\n }\n }\n\n if (diff) {\n unsigned char header = STBIW_UCHAR(len - 1);\n stbiw__write1(s, header);\n for (k = 0; k < len; ++k) {\n stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp);\n }\n } else {\n unsigned char header = STBIW_UCHAR(len - 129);\n stbiw__write1(s, header);\n stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin);\n }\n }\n }\n stbiw__write_flush(s);\n }\n return 1;\n}\n\nSTBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)\n{\n stbi__write_context s = { 0 };\n stbi__start_write_callbacks(&s, func, context);\n return stbi_write_tga_core(&s, x, y, comp, (void *) data);\n}\n\n#ifndef STBI_WRITE_NO_STDIO\nSTBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data)\n{\n stbi__write_context s = { 0 };\n if (stbi__start_write_file(&s,filename)) {\n int r = stbi_write_tga_core(&s, x, y, comp, (void *) data);\n stbi__end_write_file(&s);\n return r;\n } else\n return 0;\n}\n#endif\n\n\/\/ *************************************************************************************************\n\/\/ Radiance RGBE HDR writer\n\/\/ by Baldur Karlsson\n\n#define stbiw__max(a, b) ((a) > (b) ? (a) : (b))\n\nstatic void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear)\n{\n int exponent;\n float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2]));\n\n if (maxcomp < 1e-32f) {\n rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0;\n } else {\n float normalize = (float) frexp(maxcomp, &exponent) * 256.0f\/maxcomp;\n\n rgbe[0] = (unsigned char)(linear[0] * normalize);\n rgbe[1] = (unsigned char)(linear[1] * normalize);\n rgbe[2] = (unsigned char)(linear[2] * normalize);\n rgbe[3] = (unsigned char)(exponent + 128);\n }\n}\n\nstatic void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte)\n{\n unsigned char lengthbyte = STBIW_UCHAR(length+128);\n STBIW_ASSERT(length+128 <= 255);\n s->func(s->context, &lengthbyte, 1);\n s->func(s->context, &databyte, 1);\n}\n\nstatic void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data)\n{\n unsigned char lengthbyte = STBIW_UCHAR(length);\n STBIW_ASSERT(length <= 128); \/\/ inconsistent with spec but consistent with official code\n s->func(s->context, &lengthbyte, 1);\n s->func(s->context, data, length);\n}\n\nstatic void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline)\n{\n unsigned char scanlineheader[4] = { 2, 2, 0, 0 };\n unsigned char rgbe[4];\n float linear[3];\n int x;\n\n scanlineheader[2] = (width&0xff00)>>8;\n scanlineheader[3] = (width&0x00ff);\n\n \/* skip RLE for images too small or large *\/\n if (width < 8 || width >= 32768) {\n for (x=0; x < width; x++) {\n switch (ncomp) {\n case 4: \/* fallthrough *\/\n case 3: linear[2] = scanline[x*ncomp + 2];\n linear[1] = scanline[x*ncomp + 1];\n linear[0] = scanline[x*ncomp + 0];\n break;\n default:\n linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0];\n break;\n }\n stbiw__linear_to_rgbe(rgbe, linear);\n s->func(s->context, rgbe, 4);\n }\n } else {\n int c,r;\n \/* encode into scratch buffer *\/\n for (x=0; x < width; x++) {\n switch(ncomp) {\n case 4: \/* fallthrough *\/\n case 3: linear[2] = scanline[x*ncomp + 2];\n linear[1] = scanline[x*ncomp + 1];\n linear[0] = scanline[x*ncomp + 0];\n break;\n default:\n linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0];\n break;\n }\n stbiw__linear_to_rgbe(rgbe, linear);\n scratch[x + width*0] = rgbe[0];\n scratch[x + width*1] = rgbe[1];\n scratch[x + width*2] = rgbe[2];\n scratch[x + width*3] = rgbe[3];\n }\n\n s->func(s->context, scanlineheader, 4);\n\n \/* RLE each component separately *\/\n for (c=0; c < 4; c++) {\n unsigned char *comp = &scratch[width*c];\n\n x = 0;\n while (x < width) {\n \/\/ find first run\n r = x;\n while (r+2 < width) {\n if (comp[r] == comp[r+1] && comp[r] == comp[r+2])\n break;\n ++r;\n }\n if (r+2 >= width)\n r = width;\n \/\/ dump up to first run\n while (x < r) {\n int len = r-x;\n if (len > 128) len = 128;\n stbiw__write_dump_data(s, len, &comp[x]);\n x += len;\n }\n \/\/ if there's a run, output it\n if (r+2 < width) { \/\/ same test as what we break out of in search loop, so only true if we break'd\n \/\/ find next byte after run\n while (r < width && comp[r] == comp[x])\n ++r;\n \/\/ output run up to r\n while (x < r) {\n int len = r-x;\n if (len > 127) len = 127;\n stbiw__write_run_data(s, len, comp[x]);\n x += len;\n }\n }\n }\n }\n }\n}\n\nstatic int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data)\n{\n if (y <= 0 || x <= 0 || data == NULL)\n return 0;\n else {\n \/\/ Each component is stored separately. Allocate scratch space for full output scanline.\n unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4);\n int i, len;\n char buffer[128];\n char header[] = \"#?RADIANCE\\n# Written by stb_image_write.h\\nFORMAT=32-bit_rle_rgbe\\n\";\n s->func(s->context, header, sizeof(header)-1);\n\n#ifdef __STDC_WANT_SECURE_LIB__\n len = sprintf_s(buffer, sizeof(buffer), \"EXPOSURE= 1.0000000000000\\n\\n-Y %d +X %d\\n\", y, x);\n#else\n len = sprintf(buffer, \"EXPOSURE= 1.0000000000000\\n\\n-Y %d +X %d\\n\", y, x);\n#endif\n s->func(s->context, buffer, len);\n\n for(i=0; i < y; i++)\n stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i));\n STBIW_FREE(scratch);\n return 1;\n }\n}\n\nSTBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data)\n{\n stbi__write_context s = { 0 };\n stbi__start_write_callbacks(&s, func, context);\n return stbi_write_hdr_core(&s, x, y, comp, (float *) data);\n}\n\n#ifndef STBI_WRITE_NO_STDIO\nSTBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data)\n{\n stbi__write_context s = { 0 };\n if (stbi__start_write_file(&s,filename)) {\n int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data);\n stbi__end_write_file(&s);\n return r;\n } else\n return 0;\n}\n#endif \/\/ STBI_WRITE_NO_STDIO\n\n\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\/\/\n\/\/ PNG writer\n\/\/\n\n#ifndef STBIW_ZLIB_COMPRESS\n\/\/ stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size()\n#define stbiw__sbraw(a) ((int *) (void *) (a) - 2)\n#define stbiw__sbm(a) stbiw__sbraw(a)[0]\n#define stbiw__sbn(a) stbiw__sbraw(a)[1]\n\n#define stbiw__sbneedgrow(a,n) ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a))\n#define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0)\n#define stbiw__sbgrow(a,n) stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a)))\n\n#define stbiw__sbpush(a, v) (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v))\n#define stbiw__sbcount(a) ((a) ? stbiw__sbn(a) : 0)\n#define stbiw__sbfree(a) ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0)\n\nstatic void *stbiw__sbgrowf(void **arr, int increment, int itemsize)\n{\n int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1;\n void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2);\n STBIW_ASSERT(p);\n if (p) {\n if (!*arr) ((int *) p)[1] = 0;\n *arr = (void *) ((int *) p + 2);\n stbiw__sbm(*arr) = m;\n }\n return *arr;\n}\n\nstatic unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount)\n{\n while (*bitcount >= 8) {\n stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer));\n *bitbuffer >>= 8;\n *bitcount -= 8;\n }\n return data;\n}\n\nstatic int stbiw__zlib_bitrev(int code, int codebits)\n{\n int res=0;\n while (codebits--) {\n res = (res << 1) | (code & 1);\n code >>= 1;\n }\n return res;\n}\n\nstatic unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit)\n{\n int i;\n for (i=0; i < limit && i < 258; ++i)\n if (a[i] != b[i]) break;\n return i;\n}\n\nstatic unsigned int stbiw__zhash(unsigned char *data)\n{\n stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16);\n hash ^= hash << 3;\n hash += hash >> 5;\n hash ^= hash << 4;\n hash += hash >> 17;\n hash ^= hash << 25;\n hash += hash >> 6;\n return hash;\n}\n\n#define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount))\n#define stbiw__zlib_add(code,codebits) \\\n (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush())\n#define stbiw__zlib_huffa(b,c) stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c)\n\/\/ default huffman tables\n#define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8)\n#define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9)\n#define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256,7)\n#define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280,8)\n#define stbiw__zlib_huff(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n))\n#define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n))\n\n#define stbiw__ZHASH 16384\n\n#endif \/\/ STBIW_ZLIB_COMPRESS\n\nSTBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality)\n{\n#ifdef STBIW_ZLIB_COMPRESS\n \/\/ user provided a zlib compress implementation, use that\n return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality);\n#else \/\/ use builtin\n static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 };\n static unsigned char lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 };\n static unsigned short distc[] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 };\n static unsigned char disteb[] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 };\n unsigned int bitbuf=0;\n int i,j, bitcount=0;\n unsigned char *out = NULL;\n unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(unsigned char**));\n if (hash_table == NULL)\n return NULL;\n if (quality < 5) quality = 5;\n\n stbiw__sbpush(out, 0x78); \/\/ DEFLATE 32K window\n stbiw__sbpush(out, 0x5e); \/\/ FLEVEL = 1\n stbiw__zlib_add(1,1); \/\/ BFINAL = 1\n stbiw__zlib_add(1,2); \/\/ BTYPE = 1 -- fixed huffman\n\n for (i=0; i < stbiw__ZHASH; ++i)\n hash_table[i] = NULL;\n\n i=0;\n while (i < data_len-3) {\n \/\/ hash next 3 bytes of data to be compressed\n int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3;\n unsigned char *bestloc = 0;\n unsigned char **hlist = hash_table[h];\n int n = stbiw__sbcount(hlist);\n for (j=0; j < n; ++j) {\n if (hlist[j]-data > i-32768) { \/\/ if entry lies within window\n int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i);\n if (d >= best) { best=d; bestloc=hlist[j]; }\n }\n }\n \/\/ when hash table entry is too long, delete half the entries\n if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) {\n STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality);\n stbiw__sbn(hash_table[h]) = quality;\n }\n stbiw__sbpush(hash_table[h],data+i);\n\n if (bestloc) {\n \/\/ \"lazy matching\" - check match at *next* byte, and if it's better, do cur byte as literal\n h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1);\n hlist = hash_table[h];\n n = stbiw__sbcount(hlist);\n for (j=0; j < n; ++j) {\n if (hlist[j]-data > i-32767) {\n int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1);\n if (e > best) { \/\/ if next match is better, bail on current match\n bestloc = NULL;\n break;\n }\n }\n }\n }\n\n if (bestloc) {\n int d = (int) (data+i - bestloc); \/\/ distance back\n STBIW_ASSERT(d <= 32767 && best <= 258);\n for (j=0; best > lengthc[j+1]-1; ++j);\n stbiw__zlib_huff(j+257);\n if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]);\n for (j=0; d > distc[j+1]-1; ++j);\n stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5);\n if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]);\n i += best;\n } else {\n stbiw__zlib_huffb(data[i]);\n ++i;\n }\n }\n \/\/ write out final bytes\n for (;i < data_len; ++i)\n stbiw__zlib_huffb(data[i]);\n stbiw__zlib_huff(256); \/\/ end of block\n \/\/ pad with 0 bits to byte boundary\n while (bitcount)\n stbiw__zlib_add(0,1);\n\n for (i=0; i < stbiw__ZHASH; ++i)\n (void) stbiw__sbfree(hash_table[i]);\n STBIW_FREE(hash_table);\n\n {\n \/\/ compute adler32 on input\n unsigned int s1=1, s2=0;\n int blocklen = (int) (data_len % 5552);\n j=0;\n while (j < data_len) {\n for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; }\n s1 %= 65521; s2 %= 65521;\n j += blocklen;\n blocklen = 5552;\n }\n stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8));\n stbiw__sbpush(out, STBIW_UCHAR(s2));\n stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8));\n stbiw__sbpush(out, STBIW_UCHAR(s1));\n }\n *out_len = stbiw__sbn(out);\n \/\/ make returned pointer freeable\n STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len);\n return (unsigned char *) stbiw__sbraw(out);\n#endif \/\/ STBIW_ZLIB_COMPRESS\n}\n\nstatic unsigned int stbiw__crc32(unsigned char *buffer, int len)\n{\n#ifdef STBIW_CRC32\n return STBIW_CRC32(buffer, len);\n#else\n static unsigned int crc_table[256] =\n {\n 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,\n 0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,\n 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,\n 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,\n 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,\n 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,\n 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,\n 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,\n 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,\n 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,\n 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,\n 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,\n 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,\n 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,\n 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,\n 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,\n 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,\n 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,\n 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,\n 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,\n 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,\n 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,\n 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,\n 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,\n 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,\n 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,\n 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,\n 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,\n 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,\n 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,\n 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,\n 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D\n };\n\n unsigned int crc = ~0u;\n int i;\n for (i=0; i < len; ++i)\n crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)];\n return ~crc;\n#endif\n}\n\n#define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4)\n#define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v));\n#define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3])\n\nstatic void stbiw__wpcrc(unsigned char **data, int len)\n{\n unsigned int crc = stbiw__crc32(*data - len - 4, len+4);\n stbiw__wp32(*data, crc);\n}\n\nstatic unsigned char stbiw__paeth(int a, int b, int c)\n{\n int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c);\n if (pa <= pb && pa <= pc) return STBIW_UCHAR(a);\n if (pb <= pc) return STBIW_UCHAR(b);\n return STBIW_UCHAR(c);\n}\n\n\/\/ @OPTIMIZE: provide an option that always forces left-predict or paeth predict\nstatic void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer)\n{\n static int mapping[] = { 0,1,2,3,4 };\n static int firstmap[] = { 0,1,0,5,6 };\n int *mymap = (y != 0) ? mapping : firstmap;\n int i;\n int type = mymap[filter_type];\n unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y);\n int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes;\n\n if (type==0) {\n memcpy(line_buffer, z, width*n);\n return;\n }\n\n \/\/ first loop isn't optimized since it's just one pixel\n for (i = 0; i < n; ++i) {\n switch (type) {\n case 1: line_buffer[i] = z[i]; break;\n case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break;\n case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break;\n case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break;\n case 5: line_buffer[i] = z[i]; break;\n case 6: line_buffer[i] = z[i]; break;\n }\n }\n switch (type) {\n case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break;\n case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break;\n case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break;\n case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break;\n case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break;\n case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break;\n }\n}\n\nSTBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)\n{\n int force_filter = stbi_write_force_png_filter;\n int ctype[5] = { -1, 0, 4, 2, 6 };\n unsigned char sig[8] = { 137,80,78,71,13,10,26,10 };\n unsigned char *out,*o, *filt, *zlib;\n signed char *line_buffer;\n int j,zlen;\n\n if (stride_bytes == 0)\n stride_bytes = x * n;\n\n if (force_filter >= 5) {\n force_filter = -1;\n }\n\n filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0;\n line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; }\n for (j=0; j < y; ++j) {\n int filter_type;\n if (force_filter > -1) {\n filter_type = force_filter;\n stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer);\n } else { \/\/ Estimate the best filter by running through all of them:\n int best_filter = 0, best_filter_val = 0x7fffffff, est, i;\n for (filter_type = 0; filter_type < 5; filter_type++) {\n stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer);\n\n \/\/ Estimate the entropy of the line using this filter; the less, the better.\n est = 0;\n for (i = 0; i < x*n; ++i) {\n est += abs((signed char) line_buffer[i]);\n }\n if (est < best_filter_val) {\n best_filter_val = est;\n best_filter = filter_type;\n }\n }\n if (filter_type != best_filter) { \/\/ If the last iteration already got us the best filter, don't redo it\n stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer);\n filter_type = best_filter;\n }\n }\n \/\/ when we get here, filter_type contains the filter type, and line_buffer contains the data\n filt[j*(x*n+1)] = (unsigned char) filter_type;\n STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n);\n }\n STBIW_FREE(line_buffer);\n zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level);\n STBIW_FREE(filt);\n if (!zlib) return 0;\n\n \/\/ each tag requires 12 bytes of overhead\n out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12);\n if (!out) return 0;\n *out_len = 8 + 12+13 + 12+zlen + 12;\n\n o=out;\n STBIW_MEMMOVE(o,sig,8); o+= 8;\n stbiw__wp32(o, 13); \/\/ header length\n stbiw__wptag(o, \"IHDR\");\n stbiw__wp32(o, x);\n stbiw__wp32(o, y);\n *o++ = 8;\n *o++ = STBIW_UCHAR(ctype[n]);\n *o++ = 0;\n *o++ = 0;\n *o++ = 0;\n stbiw__wpcrc(&o,13);\n\n stbiw__wp32(o, zlen);\n stbiw__wptag(o, \"IDAT\");\n STBIW_MEMMOVE(o, zlib, zlen);\n o += zlen;\n STBIW_FREE(zlib);\n stbiw__wpcrc(&o, zlen);\n\n stbiw__wp32(o,0);\n stbiw__wptag(o, \"IEND\");\n stbiw__wpcrc(&o,0);\n\n STBIW_ASSERT(o == out + *out_len);\n\n return out;\n}\n\n#ifndef STBI_WRITE_NO_STDIO\nSTBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes)\n{\n FILE *f;\n int len;\n unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);\n if (png == NULL) return 0;\n\n f = stbiw__fopen(filename, \"wb\");\n if (!f) { STBIW_FREE(png); return 0; }\n fwrite(png, 1, len, f);\n fclose(f);\n STBIW_FREE(png);\n return 1;\n}\n#endif\n\nSTBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes)\n{\n int len;\n unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);\n if (png == NULL) return 0;\n func(context, png, len);\n STBIW_FREE(png);\n return 1;\n}\n\n\n\/* ***************************************************************************\n *\n * JPEG writer\n *\n * This is based on Jon Olick's jo_jpeg.cpp:\n * public domain Simple, Minimalistic JPEG writer - http:\/\/www.jonolick.com\/code.html\n *\/\n\nstatic const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,\n 24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 };\n\nstatic void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) {\n int bitBuf = *bitBufP, bitCnt = *bitCntP;\n bitCnt += bs[1];\n bitBuf |= bs[0] << (24 - bitCnt);\n while(bitCnt >= 8) {\n unsigned char c = (bitBuf >> 16) & 255;\n stbiw__putc(s, c);\n if(c == 255) {\n stbiw__putc(s, 0);\n }\n bitBuf <<= 8;\n bitCnt -= 8;\n }\n *bitBufP = bitBuf;\n *bitCntP = bitCnt;\n}\n\nstatic void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) {\n float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p;\n float z1, z2, z3, z4, z5, z11, z13;\n\n float tmp0 = d0 + d7;\n float tmp7 = d0 - d7;\n float tmp1 = d1 + d6;\n float tmp6 = d1 - d6;\n float tmp2 = d2 + d5;\n float tmp5 = d2 - d5;\n float tmp3 = d3 + d4;\n float tmp4 = d3 - d4;\n\n \/\/ Even part\n float tmp10 = tmp0 + tmp3; \/\/ phase 2\n float tmp13 = tmp0 - tmp3;\n float tmp11 = tmp1 + tmp2;\n float tmp12 = tmp1 - tmp2;\n\n d0 = tmp10 + tmp11; \/\/ phase 3\n d4 = tmp10 - tmp11;\n\n z1 = (tmp12 + tmp13) * 0.707106781f; \/\/ c4\n d2 = tmp13 + z1; \/\/ phase 5\n d6 = tmp13 - z1;\n\n \/\/ Odd part\n tmp10 = tmp4 + tmp5; \/\/ phase 2\n tmp11 = tmp5 + tmp6;\n tmp12 = tmp6 + tmp7;\n\n \/\/ The rotator is modified from fig 4-8 to avoid extra negations.\n z5 = (tmp10 - tmp12) * 0.382683433f; \/\/ c6\n z2 = tmp10 * 0.541196100f + z5; \/\/ c2-c6\n z4 = tmp12 * 1.306562965f + z5; \/\/ c2+c6\n z3 = tmp11 * 0.707106781f; \/\/ c4\n\n z11 = tmp7 + z3; \/\/ phase 5\n z13 = tmp7 - z3;\n\n *d5p = z13 + z2; \/\/ phase 6\n *d3p = z13 - z2;\n *d1p = z11 + z4;\n *d7p = z11 - z4;\n\n *d0p = d0; *d2p = d2; *d4p = d4; *d6p = d6;\n}\n\nstatic void stbiw__jpg_calcBits(int val, unsigned short bits[2]) {\n int tmp1 = val < 0 ? -val : val;\n val = val < 0 ? val-1 : val;\n bits[1] = 1;\n while(tmp1 >>= 1) {\n ++bits[1];\n }\n bits[0] = val & ((1<0)&&(DU[end0pos]==0); --end0pos) {\n }\n \/\/ end0pos = first element in reverse order !=0\n if(end0pos == 0) {\n stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB);\n return DU[0];\n }\n for(i = 1; i <= end0pos; ++i) {\n int startpos = i;\n int nrzeroes;\n unsigned short bits[2];\n for (; DU[i]==0 && i<=end0pos; ++i) {\n }\n nrzeroes = i-startpos;\n if ( nrzeroes >= 16 ) {\n int lng = nrzeroes>>4;\n int nrmarker;\n for (nrmarker=1; nrmarker <= lng; ++nrmarker)\n stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes);\n nrzeroes &= 15;\n }\n stbiw__jpg_calcBits(DU[i], bits);\n stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]);\n stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);\n }\n if(end0pos != 63) {\n stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB);\n }\n return DU[0];\n}\n\nstatic int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) {\n \/\/ Constants that don't pollute global namespace\n static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0};\n static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};\n static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d};\n static const unsigned char std_ac_luminance_values[] = {\n 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08,\n 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28,\n 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59,\n 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89,\n 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6,\n 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2,\n 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa\n };\n static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0};\n static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};\n static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77};\n static const unsigned char std_ac_chrominance_values[] = {\n 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91,\n 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26,\n 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,\n 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87,\n 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,\n 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,\n 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa\n };\n \/\/ Huffman tables\n static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}};\n static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}};\n static const unsigned short YAC_HT[256][2] = {\n {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0},\n {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0}\n };\n static const unsigned short UVAC_HT[256][2] = {\n {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0},\n {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0}\n };\n static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,\n 37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99};\n static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,\n 99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99};\n static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f,\n 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f };\n\n int row, col, i, k, subsample;\n float fdtbl_Y[64], fdtbl_UV[64];\n unsigned char YTable[64], UVTable[64];\n\n if(!data || !width || !height || comp > 4 || comp < 1) {\n return 0;\n }\n\n quality = quality ? quality : 90;\n subsample = quality <= 90 ? 1 : 0;\n quality = quality < 1 ? 1 : quality > 100 ? 100 : quality;\n quality = quality < 50 ? 5000 \/ quality : 200 - quality * 2;\n\n for(i = 0; i < 64; ++i) {\n int uvti, yti = (YQT[i]*quality+50)\/100;\n YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti);\n uvti = (UVQT[i]*quality+50)\/100;\n UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti);\n }\n\n for(row = 0, k = 0; row < 8; ++row) {\n for(col = 0; col < 8; ++col, ++k) {\n fdtbl_Y[k] = 1 \/ (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]);\n fdtbl_UV[k] = 1 \/ (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]);\n }\n }\n\n \/\/ Write Headers\n {\n static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 };\n static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 };\n const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width),\n 3,1,(unsigned char)(subsample?0x22:0x11),0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 };\n s->func(s->context, (void*)head0, sizeof(head0));\n s->func(s->context, (void*)YTable, sizeof(YTable));\n stbiw__putc(s, 1);\n s->func(s->context, UVTable, sizeof(UVTable));\n s->func(s->context, (void*)head1, sizeof(head1));\n s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1);\n s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values));\n stbiw__putc(s, 0x10); \/\/ HTYACinfo\n s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1);\n s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values));\n stbiw__putc(s, 1); \/\/ HTUDCinfo\n s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1);\n s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values));\n stbiw__putc(s, 0x11); \/\/ HTUACinfo\n s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1);\n s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values));\n s->func(s->context, (void*)head2, sizeof(head2));\n }\n\n \/\/ Encode 8x8 macroblocks\n {\n static const unsigned short fillBits[] = {0x7F, 7};\n int DCY=0, DCU=0, DCV=0;\n int bitBuf=0, bitCnt=0;\n \/\/ comp == 2 is grey+alpha (alpha is ignored)\n int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0;\n const unsigned char *dataR = (const unsigned char *)data;\n const unsigned char *dataG = dataR + ofsG;\n const unsigned char *dataB = dataR + ofsB;\n int x, y, pos;\n if(subsample) {\n for(y = 0; y < height; y += 16) {\n for(x = 0; x < width; x += 16) {\n float Y[256], U[256], V[256];\n for(row = y, pos = 0; row < y+16; ++row) {\n \/\/ row >= height => use last input row\n int clamped_row = (row < height) ? row : height - 1;\n int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp;\n for(col = x; col < x+16; ++col, ++pos) {\n \/\/ if col >= width => use pixel from last input column\n int p = base_p + ((col < width) ? col : (width-1))*comp;\n float r = dataR[p], g = dataG[p], b = dataB[p];\n Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128;\n U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b;\n V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b;\n }\n }\n DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+0, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);\n DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+8, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);\n DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+128, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);\n DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+136, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);\n\n \/\/ subsample U,V\n {\n float subU[64], subV[64];\n int yy, xx;\n for(yy = 0, pos = 0; yy < 8; ++yy) {\n for(xx = 0; xx < 8; ++xx, ++pos) {\n int j = yy*32+xx*2;\n subU[pos] = (U[j+0] + U[j+1] + U[j+16] + U[j+17]) * 0.25f;\n subV[pos] = (V[j+0] + V[j+1] + V[j+16] + V[j+17]) * 0.25f;\n }\n }\n DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subU, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);\n DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subV, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);\n }\n }\n }\n } else {\n for(y = 0; y < height; y += 8) {\n for(x = 0; x < width; x += 8) {\n float Y[64], U[64], V[64];\n for(row = y, pos = 0; row < y+8; ++row) {\n \/\/ row >= height => use last input row\n int clamped_row = (row < height) ? row : height - 1;\n int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp;\n for(col = x; col < x+8; ++col, ++pos) {\n \/\/ if col >= width => use pixel from last input column\n int p = base_p + ((col < width) ? col : (width-1))*comp;\n float r = dataR[p], g = dataG[p], b = dataB[p];\n Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128;\n U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b;\n V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b;\n }\n }\n\n DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y, 8, fdtbl_Y, DCY, YDC_HT, YAC_HT);\n DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, U, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);\n DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, V, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);\n }\n }\n }\n\n \/\/ Do the bit alignment of the EOI marker\n stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits);\n }\n\n \/\/ EOI\n stbiw__putc(s, 0xFF);\n stbiw__putc(s, 0xD9);\n\n return 1;\n}\n\nSTBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality)\n{\n stbi__write_context s = { 0 };\n stbi__start_write_callbacks(&s, func, context);\n return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality);\n}\n\n\n#ifndef STBI_WRITE_NO_STDIO\nSTBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality)\n{\n stbi__write_context s = { 0 };\n if (stbi__start_write_file(&s,filename)) {\n int r = stbi_write_jpg_core(&s, x, y, comp, data, quality);\n stbi__end_write_file(&s);\n return r;\n } else\n return 0;\n}\n#endif\n\n#endif \/\/ STB_IMAGE_WRITE_IMPLEMENTATION\n\n\/* Revision history\n 1.14 (2020-02-02) updated JPEG writer to downsample chroma channels\n 1.13\n 1.12\n 1.11 (2019-08-11)\n 1.10 (2019-02-07)\n support utf8 filenames in Windows; fix warnings and platform ifdefs\n 1.09 (2018-02-11)\n fix typo in zlib quality API, improve STB_I_W_STATIC in C++\n 1.08 (2018-01-29)\n add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter\n 1.07 (2017-07-24)\n doc fix\n 1.06 (2017-07-23)\n writing JPEG (using Jon Olick's code)\n 1.05 ???\n 1.04 (2017-03-03)\n monochrome BMP expansion\n 1.03 ???\n 1.02 (2016-04-02)\n avoid allocating large structures on the stack\n 1.01 (2016-01-16)\n STBIW_REALLOC_SIZED: support allocators with no realloc support\n avoid race-condition in crc initialization\n minor compile issues\n 1.00 (2015-09-14)\n installable file IO function\n 0.99 (2015-09-13)\n warning fixes; TGA rle support\n 0.98 (2015-04-08)\n added STBIW_MALLOC, STBIW_ASSERT etc\n 0.97 (2015-01-18)\n fixed HDR asserts, rewrote HDR rle logic\n 0.96 (2015-01-17)\n add HDR output\n fix monochrome BMP\n 0.95 (2014-08-17)\n\t\t add monochrome TGA output\n 0.94 (2014-05-31)\n rename private functions to avoid conflicts with stb_image.h\n 0.93 (2014-05-27)\n warning fixes\n 0.92 (2010-08-01)\n casts to unsigned char to fix warnings\n 0.91 (2010-07-17)\n first public release\n 0.90 first internal release\n*\/\n\n\/*\n------------------------------------------------------------------------------\nThis software is available under 2 licenses -- choose whichever you prefer.\n------------------------------------------------------------------------------\nALTERNATIVE A - MIT License\nCopyright (c) 2017 Sean Barrett\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and\/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n------------------------------------------------------------------------------\nALTERNATIVE B - Public Domain (www.unlicense.org)\nThis is free and unencumbered software released into the public domain.\nAnyone is free to copy, modify, publish, use, compile, sell, or distribute this\nsoftware, either in source code form or as a compiled binary, for any purpose,\ncommercial or non-commercial, and by any means.\nIn jurisdictions that recognize copyright laws, the author or authors of this\nsoftware dedicate any and all copyright interest in the software to the public\ndomain. We make this dedication for the benefit of the public at large and to\nthe detriment of our heirs and successors. We intend this dedication to be an\novert act of relinquishment in perpetuity of all present and future rights to\nthis software under copyright law.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\nACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n------------------------------------------------------------------------------\n*\/","avg_line_length":42.0611010284,"max_line_length":205,"alphanum_fraction":0.6104247271} +{"size":216,"ext":"h","lang":"C","max_stars_count":1.0,"content":"\/\/\n\/\/ RYJViewController.h\n\/\/ RYJToolKit\n\/\/\n\/\/ Created by developRen on 11\/30\/2020.\n\/\/ Copyright (c) 2020 developRen. All rights reserved.\n\/\/\n\n@import UIKit;\n\n@interface RYJViewController : UIViewController\n\n@end\n","avg_line_length":15.4285714286,"max_line_length":55,"alphanum_fraction":0.712962963} +{"size":1867,"ext":"c","lang":"C","max_stars_count":null,"content":"\/* ************************************************************************** *\/\n\/* *\/\n\/* ::: :::::::: *\/\n\/* vm2.c :+: :+: :+: *\/\n\/* +:+ +:+ +:+ *\/\n\/* By: rpoetess +#+ +:+ +#+ *\/\n\/* +#+#+#+#+#+ +#+ *\/\n\/* Created: 2020\/02\/05 19:51:16 by rpoetess #+# #+# *\/\n\/* Updated: 2020\/02\/05 19:51:18 by rpoetess ### ########.fr *\/\n\/* *\/\n\/* ************************************************************************** *\/\n\n#include \"libft.h\"\n#include \"vm.h\"\n\nuint\t\tmem_mod(long int pc)\n{\n\twhile (pc < 0)\n\t\tpc += MEM_SIZE;\n\treturn (pc % MEM_SIZE);\n}\n\nvoid\t\tt_vm_init(t_vm *vm, int n_champs, t_args args)\n{\n\tft_bzero(vm, sizeof(t_vm));\n\tvm->mode = args.mode;\n\tvm->v_flag = args.v_flag;\n\tvm->n_champs = n_champs;\n\tvm->mem = ft_calloc(MEM_SIZE, sizeof(char));\n\tvm->host_endian = endian();\n\tvm->cycles_to_die = CYCLE_TO_DIE;\n\tvm->i_before_check = vm->cycles_to_die;\n\tt_arrayp_init(&vm->procs);\n\tif (vm->mode == MODE_VIS)\n\t\twrite_init();\n}\n\nvoid\t\tt_vm_print(t_vm *vm)\n{\n\tint\ti;\n\n\ti = -1;\n\twhile (++i < MEM_SIZE)\n\t{\n\t\tif (!(i % OCTETS_PER_LINE))\n\t\t\tft_printf(\"0x%04x : \", i);\n\t\tput_hex(vm->mem[i], 2);\n\t\tft_printf(\" \");\n\t\tif (!((i + 1) % OCTETS_PER_LINE))\n\t\t\tft_printf(\"\\n\");\n\t}\n}\n\nvoid\t\tput_hex(uint v, int digits)\n{\n\tunsigned int\ta;\n\tunsigned int\tb;\n\n\tif (!digits)\n\t\treturn ;\n\ta = v \/ 16;\n\tb = v - a * 16;\n\tput_hex(a, digits - 1);\n\tif (b < 10)\n\t\tft_putchar('0' + b);\n\telse\n\t\tft_putchar('a' - 10 + b);\n}\n","avg_line_length":27.0579710145,"max_line_length":80,"alphanum_fraction":0.362613819} +{"size":5219,"ext":"h","lang":"C","max_stars_count":1.0,"content":"\ufeff\/*\n* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\").\n* You may not use this file except in compliance with the License.\n* A copy of the License is located at\n*\n* http:\/\/aws.amazon.com\/apache2.0\n*\n* or in the \"license\" file accompanying this file. This file is distributed\n* on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n* express or implied. See the License for the specific language governing\n* permissions and limitations under the License.\n*\/\n\n#pragma once\n#include \n#include \n#include \n#include \n\nnamespace Aws\n{\nnamespace Utils\n{\nnamespace Json\n{\n class JsonValue;\n} \/\/ namespace Json\n} \/\/ namespace Utils\nnamespace KinesisAnalytics\n{\nnamespace Model\n{\n\n \/**\n *

Provides application summary information, including the application Amazon\n * Resource Name (ARN), name, and status.<\/p>

See Also:<\/h3> AWS\n * API Reference<\/a><\/p>\n *\/\n class AWS_KINESISANALYTICS_API ApplicationSummary\n {\n public:\n ApplicationSummary();\n ApplicationSummary(const Aws::Utils::Json::JsonValue& jsonValue);\n ApplicationSummary& operator=(const Aws::Utils::Json::JsonValue& jsonValue);\n Aws::Utils::Json::JsonValue Jsonize() const;\n\n\n \/**\n *

Name of the application.<\/p>\n *\/\n inline const Aws::String& GetApplicationName() const{ return m_applicationName; }\n\n \/**\n *

Name of the application.<\/p>\n *\/\n inline void SetApplicationName(const Aws::String& value) { m_applicationNameHasBeenSet = true; m_applicationName = value; }\n\n \/**\n *

Name of the application.<\/p>\n *\/\n inline void SetApplicationName(Aws::String&& value) { m_applicationNameHasBeenSet = true; m_applicationName = std::move(value); }\n\n \/**\n *

Name of the application.<\/p>\n *\/\n inline void SetApplicationName(const char* value) { m_applicationNameHasBeenSet = true; m_applicationName.assign(value); }\n\n \/**\n *

Name of the application.<\/p>\n *\/\n inline ApplicationSummary& WithApplicationName(const Aws::String& value) { SetApplicationName(value); return *this;}\n\n \/**\n *

Name of the application.<\/p>\n *\/\n inline ApplicationSummary& WithApplicationName(Aws::String&& value) { SetApplicationName(std::move(value)); return *this;}\n\n \/**\n *

Name of the application.<\/p>\n *\/\n inline ApplicationSummary& WithApplicationName(const char* value) { SetApplicationName(value); return *this;}\n\n\n \/**\n *

ARN of the application.<\/p>\n *\/\n inline const Aws::String& GetApplicationARN() const{ return m_applicationARN; }\n\n \/**\n *

ARN of the application.<\/p>\n *\/\n inline void SetApplicationARN(const Aws::String& value) { m_applicationARNHasBeenSet = true; m_applicationARN = value; }\n\n \/**\n *

ARN of the application.<\/p>\n *\/\n inline void SetApplicationARN(Aws::String&& value) { m_applicationARNHasBeenSet = true; m_applicationARN = std::move(value); }\n\n \/**\n *

ARN of the application.<\/p>\n *\/\n inline void SetApplicationARN(const char* value) { m_applicationARNHasBeenSet = true; m_applicationARN.assign(value); }\n\n \/**\n *

ARN of the application.<\/p>\n *\/\n inline ApplicationSummary& WithApplicationARN(const Aws::String& value) { SetApplicationARN(value); return *this;}\n\n \/**\n *

ARN of the application.<\/p>\n *\/\n inline ApplicationSummary& WithApplicationARN(Aws::String&& value) { SetApplicationARN(std::move(value)); return *this;}\n\n \/**\n *

ARN of the application.<\/p>\n *\/\n inline ApplicationSummary& WithApplicationARN(const char* value) { SetApplicationARN(value); return *this;}\n\n\n \/**\n *

Status of the application.<\/p>\n *\/\n inline const ApplicationStatus& GetApplicationStatus() const{ return m_applicationStatus; }\n\n \/**\n *

Status of the application.<\/p>\n *\/\n inline void SetApplicationStatus(const ApplicationStatus& value) { m_applicationStatusHasBeenSet = true; m_applicationStatus = value; }\n\n \/**\n *

Status of the application.<\/p>\n *\/\n inline void SetApplicationStatus(ApplicationStatus&& value) { m_applicationStatusHasBeenSet = true; m_applicationStatus = std::move(value); }\n\n \/**\n *

Status of the application.<\/p>\n *\/\n inline ApplicationSummary& WithApplicationStatus(const ApplicationStatus& value) { SetApplicationStatus(value); return *this;}\n\n \/**\n *

Status of the application.<\/p>\n *\/\n inline ApplicationSummary& WithApplicationStatus(ApplicationStatus&& value) { SetApplicationStatus(std::move(value)); return *this;}\n\n private:\n\n Aws::String m_applicationName;\n bool m_applicationNameHasBeenSet;\n\n Aws::String m_applicationARN;\n bool m_applicationARNHasBeenSet;\n\n ApplicationStatus m_applicationStatus;\n bool m_applicationStatusHasBeenSet;\n };\n\n} \/\/ namespace Model\n} \/\/ namespace KinesisAnalytics\n} \/\/ namespace Aws\n","avg_line_length":32.018404908,"max_line_length":145,"alphanum_fraction":0.689595708} +{"size":8503,"ext":"h","lang":"C","max_stars_count":443.0,"content":"\/* -------------------------------------------------------------------------\r\n\/\/ Venus: A High Performance async server framework\r\n\/\/ \r\n\/\/ Module: venus\/connection\/active.h\r\n\/\/ Creator: Li Jie\r\n\/\/ Email: cpunion@gmail.com\r\n\/\/ Date: 2010-5-10 13:55:00\r\n\/\/ \r\n\/\/ $Id: active.h 2754 2010-05-05 10:25:27Z lijie $\r\n\/\/ -----------------------------------------------------------------------*\/\r\n#ifndef VENUS_CONN_ACTIVE_H\r\n#define VENUS_CONN_ACTIVE_H\r\n\r\n#ifndef VENUS_BASIC_H\r\n#include \"..\/Basic.h\"\r\n#endif\r\n\r\n#ifndef VENUS_IO_H\r\n#include \"..\/Io.h\"\r\n#endif\r\n\r\n#ifndef VENUS_MAIL_H\r\n#include \"..\/Mail.h\"\r\n#endif\r\n\r\n#ifndef STDEXT_HASHMAP_H\r\n#include \"..\/..\/..\/..\/stdext\/include\/stdext\/HashMap.h\"\r\n#endif\r\n\r\n#include \r\n\r\nNS_CERL_BEGIN\r\n\r\n\/\/ -------------------------------------------------------------------------\r\n\/\/ class ConnectionImpl\r\n\r\nclass ConnectionImpl\r\n{\r\nprivate:\r\n\tConnectionImpl(const ConnectionImpl&);\r\n\tConnectionImpl& operator=(const ConnectionImpl&);\r\n\r\nprotected:\r\n\ttypedef MailReader Reader;\r\n\ttypedef BufferedWriter Writer;\r\n\t\r\n\tenum { InvalidMailNo = -1 };\r\n\tenum { MailNoMask = 0x7FFFFFFF };\r\n\r\n\ttypedef bool (cerl_callback *GetProc)(Reader& ar, void* param);\r\n\r\n\tstruct RecvInfo\r\n\t{\r\n\t\tScopedAlloc* alloc;\r\n\t\tGetProc proc;\r\n\t\tvoid* param;\r\n\t\tbool result;\r\n\t\tFiber fiber;\r\n\t};\r\n\r\n\ttypedef NS_STDEXT::map RecvMap;\r\n\t\/\/ callback information\r\n\tRecvMap receivers;\r\n\r\n\tNInformation const host;\r\n\tSocketFileObject file;\r\n\tSocketFile fileR;\r\n\tSocketFile fileW;\r\n\tPool& msgBufPool;\r\n\r\n\t\/\/ wait for receiver fiber\r\n\tFiberMutex mutexR;\r\n\t\/\/ make writers queuing\r\n\tFiberMutex mutexW;\r\n\r\n\tWriter writer;\r\n\tReader reader;\r\n\tUINT32 currMailNo;\r\n\tbool autoReconnect;\r\n\r\npublic:\r\n\tConnectionImpl(\r\n\t\tSOCKET socket, const NInformation& hostArg, Pool& msgBufPoolArg)\r\n\t\t: host(hostArg), fileR(file), fileW(file), msgBufPool(msgBufPoolArg), \r\n\t\t writer(fileW, (char*)msgBufPool.allocate(), msgBufPool.alloc_size()),\r\n\t\t reader(fileR, (char*)msgBufPool.allocate(), msgBufPool.alloc_size()),\r\n\t\t currMailNo(0), autoReconnect(true)\r\n\t{\r\n\t\tFiber self = getCurrentFiber();\r\n\t\topen_handle(self, socket);\r\n\t}\r\n\r\n\t~ConnectionImpl()\r\n\t{\r\n\t\tmsgBufPool.deallocate((void*)writer.get_buffer(), msgBufPool.alloc_size());\r\n\t\tmsgBufPool.deallocate((void*)reader.get_buffer(), msgBufPool.alloc_size());\r\n\r\n\t\tif (file.good() && owner())\r\n\t\t\tfile.close();\r\n\r\n\t\t\/\/ wait for receiving fiber to quit\r\n\t\tCERL_VLOG(\"Connection\", (\"wait for receiving fiber\\n\"));\r\n\t\tFiber self = getCurrentFiber();\r\n\t\tScopedLock guard(self, mutexR);\r\n\t}\r\n\r\n\tvoid set_auto_reconnect(bool b)\r\n\t{\r\n\t\tautoReconnect = b;\r\n\t}\r\n\r\n\tconst NInformation& get_host() const\r\n\t{\r\n\t\treturn host;\r\n\t}\r\n\r\n\tbool cerl_call good() const\r\n\t{\r\n\t\treturn file.good();\r\n\t}\r\n\r\npublic:\r\n\tvoid cerl_call set_timeout(Timeout to)\r\n\t{\r\n\t\tfile.set_read_timeout(to);\r\n\t\tfile.set_write_timeout(to);\r\n\t}\r\n\r\n\tTimeout cerl_call get_timeout() const\r\n\t{\r\n\t\treturn file.get_write_timeout();\r\n\t}\r\n\r\nprivate:\r\n\r\n\tbool owner() const\r\n\t{\r\n\t\treturn !(NInformation() == host);\r\n\t}\r\n\r\n\tHRESULT cerl_call reopen(Fiber self, const NInformation& host)\r\n\t{\r\n\t\tCERL_ASSERT(!file.good());\r\n\r\n\t\tif (!owner())\r\n\t\t\treturn E_ACCESSDENIED;\r\n\r\n\t\t\/\/ wait for receiving fiber to quit\r\n\t\tCERL_VLOG(\"Connection\", (\"wait for receiving fiber\\n\"));\r\n\t\tScopedLock guard(self, mutexR);\r\n\r\n\t\treader.clear();\r\n\t\twriter.clear();\r\n\t\tSOCKET socket = connectSocket(self, host);\r\n\t\t\/\/ todo: error process on connect failed.\r\n\t\treturn open_handle(self, socket);\r\n\t}\r\n\r\n\tHRESULT cerl_call open_handle(Fiber self, SOCKET socket)\r\n\t{\r\n\t\tHRESULT result = file.open_handle(socket);\r\n\r\n\t\tif (file.good())\r\n\t\t{\r\n\t\t\tfile.set_read_timeout(CERL_INFINITE);\r\n\t\t\tfile.set_write_timeout(CERL_INFINITE);\r\n\t\t\tCerlIoService(self)->startFiber(self, ReceiverMain, this, VENUS_CONNECTION_STACKSIZE);\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\ttemplate \r\n\tbool cerl_call send(Fiber self, MailNo mailno, FID fid, const ArgsT& args)\r\n\t{\r\n\t\tMailHeader header = { sizeof(MailHeader), 0, VENUS_MAIL_MAGIC_CODE, mailno, fid };\r\n\r\n\t\tfileW.setFiber(self);\r\n\r\n\t\tNS_STDEXT_IO_BINARY::put_struct(writer, header);\r\n\t\t\r\n\t\treturn NS_CERL::putMailBody(writer, args) && writer.flush();\r\n\t}\r\n\r\n\ttemplate \r\n\tstruct Traits\r\n\t{\r\n\t\tstatic bool cerl_callback getMailBody(Reader& ar, void* param)\r\n\t\t{\r\n\t\t\treturn cerl::getMailBody(ar, *(ResultT*)param);\r\n\t\t}\r\n\t};\r\n\r\npublic:\r\n\ttemplate \r\n\tbool cerl_call cast(FID fid, const ArgsT& args)\r\n\t{\r\n\t\tCERL_ASSERT(this);\r\n\t\tFiber self = cerl::getCurrentFiber();\r\n\r\n\t\tMailNo const mailno = (++currMailNo & MailNoMask);\r\n\t\tTimeout timeout = get_timeout();\r\n\t\tif (!mutexW.timed_acquire(self, timeout))\r\n\t\t{\r\n\t\t\tCERL_WARN(\"Connection\", (\"WARN: wait to write timeout\\n\"));\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tif (!good() && autoReconnect && reopen(self, host) != S_OK)\r\n\t\t{\r\n\t\t\tmutexW.release();\r\n\t\t\tCERL_WARN(\"Connection\", (\"WARN: connection lost!\\n\"));\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tconst bool b = send(self, mailno, fid, args);\r\n\t\tmutexW.release();\r\n\t\treturn b;\r\n\t}\r\n\r\n\ttemplate \r\n\tbool cerl_call call(ScopedAlloc& alloc, ResultT& result, FID fid, const ArgsT& args)\r\n\t{\r\n\t\tCERL_ASSERT(this);\r\n\t\tFiber self = cerl::getCurrentFiber();\r\n\r\n\t\tMailNo const mailno = (++currMailNo & MailNoMask);\r\n\t\tCERL_VLOG(\"Connection\", (\"INFO: SEND MailNo: %d\\n\", (int)mailno));\r\n\r\n\t\tTimeout timeout = get_timeout();\r\n\t\tif (!mutexW.timed_acquire(self, timeout))\r\n\t\t{\r\n\t\t\tCERL_WARN(\"Connection\", (\"WARN: wait to write timeout\\n\"));\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tif (!good() && autoReconnect && reopen(self, host) != S_OK)\r\n\t\t{\r\n\t\t\tmutexW.release();\r\n\t\t\tCERL_WARN(\"Connection\", (\"WARN: connection lost!\\n\"));\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tRecvInfo info;\r\n\t\tinfo.alloc = &alloc;\r\n\t\tinfo.proc = Traits::getMailBody;\r\n\t\tinfo.param = &result;\r\n\t\tinfo.result = false;\r\n\t\tinfo.fiber = self;\r\n\t\treceivers.insert(std::make_pair(mailno, info));\r\n\r\n\t\tbool const fOk = send(self, mailno, fid, args);\r\n\r\n\t\tmutexW.release();\r\n\r\n\t\tif (!fOk)\r\n\t\t{\r\n\t\t\tCERL_WARN(\"Connection\", (\"send failed\\n\"));\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tbool succ = timed_yield(self, get_timeout());\r\n\r\n\t\treceivers.erase(mailno);\r\n\r\n\t\tif (!succ)\r\n\t\t\treturn false;\r\n\r\n\t\treturn info.result;\r\n\t}\r\n\r\nprivate:\r\n\tvoid cerl_callback receiver_(Fiber self)\r\n\t{\r\n\t\t\/\/ protect receive fiber\r\n\t\tScopedLock guard(self, mutexR);\r\n\r\n\t\tSocketFile pfile(file);\r\n\r\n\t\tReader reader(pfile, (char*)msgBufPool.allocate(), msgBufPool.alloc_size());\r\n\t\r\n\t\tMailHeader header;\r\n\r\n\t\tCERL_VLOG(\"Connection\", (\"INFO: Connection::receiver - receiver begin loop.\\n\"));\r\n\t\tfor(;;)\r\n\t\t{\r\n\t\t\tCERL_VLOG(\"Connection\", (\"INFO: Connection::receiver - get header.\\n\"));\r\n\t\t\tif (!NS_STDEXT_IO_BINARY::get_struct(reader, header)\r\n\t\t\t\t|| VENUS_MAIL_MAGIC_CODE != header.magic \r\n\t\t\t\t|| sizeof(MailHeader) != header.cbHeader)\r\n\t\t\t{\r\n\t\t\t\tCERL_WARN(\"Connection\", (\"WARN: Connection::receiver - read mail failed: mailno: %d.\\n\", header.mailno));\r\n\t\t\t\tfile.close();\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tRecvMap::iterator iterReceiver = receivers.find(header.mailno & MailNoMask);\r\n\t\t\tif (receivers.end() == iterReceiver)\r\n\t\t\t{\r\n\t\t\t\tCERL_WARN(\"Connection\", (\"DROP: mail\\n\"));\r\n\t\t\t\tskipMailBody(reader);\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\r\n\r\n\t\t\tRecvInfo& receiver = iterReceiver->second;\r\n\t\t\treader.setAlloc(receiver.alloc);\r\n\r\n\t\t\tCERL_VLOG(\"Connection\", (\"INFO: Connection::receiver - do unserialization. \\n\"));\r\n\t\t\tif (!(receiver.result = receiver.proc(reader, receiver.param)))\r\n\t\t\t{\r\n\t\t\t\tCERL_WARN(\"Connection\", (\"WARN: Connection::receiver - read mail failed!\\n\"));\r\n\t\t\t\tfile.close();\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\treceivers.erase(iterReceiver);\r\n\r\n\t\t\tCERL_VLOG(\"Connection\", (\"INFO: Connection::receiver - schedule to curr fiber. \\n\"));\r\n\t\t\tCerlIoService(self)->scheduleFiber(self);\r\n\t\t\tswitchToFiber(self, receiver.fiber);\r\n\t\t}\r\n\r\n\t\tCERL_VLOG(\"Connection\", (\"INFO: Connection::receiver cleanup ...\\n\"));\r\n\r\n\t\tRecvMap::iterator iter = receivers.begin();\r\n\t\tfor (; iter != receivers.end(); ++ iter)\r\n\t\t{\r\n\t\t\tRecvInfo& receiver = iter->second;\r\n\t\t\treceiver.result = false;\r\n\t\t\t*(Code*)receiver.param = code_socket_error;\r\n\t\t\tCerlIoService(self)->scheduleFiber(self);\r\n\t\t\tswitchToFiber(self, receiver.fiber);\r\n\t\t}\r\n\r\n\t\tCERL_VLOG(\"Connection\", (\"receiving fiber exit\\n\"));\r\n\t}\r\n\t\r\n\tstatic void cerl_callback ReceiverMain(LPVOID lpParam)\r\n\t{\r\n\t\tFiberParam p(lpParam);\r\n\t\t((ConnectionImpl*)p.val)->receiver_(p.self);\r\n\t}\r\n};\r\n\r\n\/\/ -------------------------------------------------------------------------\r\n\r\nNS_CERL_END\r\n\r\n#endif\r\n","avg_line_length":24.2250712251,"max_line_length":110,"alphanum_fraction":0.6375396919} +{"size":1609,"ext":"h","lang":"C","max_stars_count":null,"content":"\/\/ Copyright (c) 2012-2014 The Ruxcoin Core developers\n\/\/ Distributed under the MIT software license, see the accompanying\n\/\/ file COPYING or http:\/\/www.opensource.org\/licenses\/mit-license.php.\n\n#ifndef RUXCOIN_VERSION_H\n#define RUXCOIN_VERSION_H\n\n\/**\n * network protocol versioning\n *\/\n\nstatic const int PROTOCOL_VERSION = 70014;\n\n\/\/! initial proto version, to be increased after version\/verack negotiation\nstatic const int INIT_PROTO_VERSION = 209;\n\n\/\/! In this version, 'getheaders' was introduced.\nstatic const int GETHEADERS_VERSION = 31800;\n\n\/\/! disconnect from peers older than this proto version\nstatic const int MIN_PEER_PROTO_VERSION = GETHEADERS_VERSION;\n\n\/\/! nTime field added to CAddress, starting with this version;\n\/\/! if possible, avoid requesting addresses nodes older than this\nstatic const int CADDR_TIME_VERSION = 31402;\n\n\/\/! BIP 0031, pong message, is enabled for all versions AFTER this one\nstatic const int BIP0031_VERSION = 60000;\n\n\/\/! \"mempool\" command, enhanced \"getdata\" behavior starts with this version\nstatic const int MEMPOOL_GD_VERSION = 60002;\n\n\/\/! \"filter*\" commands are disabled without NODE_BLOOM after and including this version\nstatic const int NO_BLOOM_VERSION = 70011;\n\n\/\/! \"sendheaders\" command and announcing blocks with headers starts with this version\nstatic const int SENDHEADERS_VERSION = 70012;\n\n\/\/! \"feefilter\" tells peers to filter invs to you by fee starts with this version\nstatic const int FEEFILTER_VERSION = 70013;\n\n\/\/! shord-id-based block download starts with this version\nstatic const int SHORT_IDS_BLOCKS_VERSION = 70014;\n\n#endif \/\/ RUXCOIN_VERSION_H\n","avg_line_length":34.9782608696,"max_line_length":87,"alphanum_fraction":0.7855811063} +{"size":2601,"ext":"c","lang":"C","max_stars_count":19.0,"content":"\/*\n *\n * Copyright (c) 2016 - 2019\n * Stony Brook University\n * Copyright (c) 2015 - 2018\n * Los Alamos National Security, LLC.\n * Copyright (c) 2011 - 2015\n * University of Houston System and UT-Battelle, LLC.\n * Copyright (c) 2009 - 2015\n * Silicon Graphics International Corp. SHMEM is copyrighted\n * by Silicon Graphics International Corp. (SGI) The OpenSHMEM API\n * (shmem) is released by Open Source Software Solutions, Inc., under an\n * agreement with Silicon Graphics International Corp. (SGI).\n *\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * o Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * o Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * o Neither the name of the University of Houston System,\n * UT-Battelle, LLC. nor the names of its contributors may be used to\n * endorse or promote products derived from this software without specific\n * prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\n * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n *\/\n\n\n\/*\n * expected output:\n *\n * PE 0: dst = 123, fetched value = 123\n * all others: dst = 123\n *\n *\/\n\n#include \n\n#include \n\nint dst = 123;\n\nint\nmain()\n{\n int me;\n\n shmem_init();\n me = shmem_my_pe();\n\n if (me == 0) {\n const int fetched = shmem_int_atomic_fetch(&dst, 1);\n\n printf(\"%d: dst = %d, fetched value = %d\\n\", me, dst, fetched);\n }\n\n shmem_barrier_all();\n\n printf(\"%d: dst = %d\\n\", me, dst);\n\n shmem_finalize();\n\n return 0;\n}\n","avg_line_length":30.9642857143,"max_line_length":76,"alphanum_fraction":0.7058823529} +{"size":2135,"ext":"h","lang":"C","max_stars_count":11.0,"content":"\/*\n * Copyright (c) 2020 Nordic Semiconductor ASA\n *\n * SPDX-License-Identifier: Apache-2.0\n *\/\n\n\/* Forward declaration to avoid unnecessary includes. *\/\nstruct lll_adv_sync;\n\n\/* Enables CTE transmission according to provided configuration *\/\nvoid lll_df_cte_tx_enable(struct lll_adv_sync *lll_sync, const struct pdu_adv *pdu,\n\t\t\t uint32_t *cte_len_us);\n\/* Disables CTE transmission *\/\nvoid lll_df_conf_cte_tx_disable(void);\n\n\/* Allocate memory for new DF sync configuration. It will always return the same\n * pointer until buffer is swapped by lll_df_sync_cfg_latest_get operation.\n *\/\nstruct lll_df_sync_cfg *lll_df_sync_cfg_alloc(struct lll_df_sync *df_cfg,\n\t\t\t\t\t uint8_t *idx);\n\/* Returns pointer to last allocated DF sync configuration. If it is called before\n * lll_df_sync_cfg_alloc it will return pointer to memory that was recently\n * enqueued.\n *\/\nstatic inline struct lll_df_sync_cfg *lll_df_sync_cfg_peek(struct lll_df_sync *df_cfg)\n{\n\treturn &df_cfg->cfg[df_cfg->last];\n}\n\n\/* Enqueue new DF sync configuration data. *\/\nstatic inline void lll_df_sync_cfg_enqueue(struct lll_df_sync *df_cfg, uint8_t idx)\n{\n\tdf_cfg->last = idx;\n}\n\n\/* Get latest DF sync configuration data. Latest configuration data are the one\n * that were enqueued by last lll_df_sync_cfg_enqueue call.\n *\/\nstruct lll_df_sync_cfg *lll_df_sync_cfg_latest_get(struct lll_df_sync *df_cfg,\n\t\t\t\t\t\t uint8_t *is_modified);\n\/* Get current DF sync configuration data. Current configuration data\n * are the one that are available after last buffer swap done by call\n * lll_df_sync_cfg_latest_get.\n *\/\nstatic inline struct lll_df_sync_cfg *lll_df_sync_cfg_curr_get(struct lll_df_sync *df_cfg)\n{\n\treturn &df_cfg->cfg[df_cfg->first];\n}\n\n\/* Return information if DF sync configuration data were modified since last\n * call to lll_df_sync_cfg_latest_get.\n *\/\nstatic inline uint8_t lll_df_sync_cfg_is_modified(struct lll_df_sync *df_cfg)\n{\n\treturn df_cfg->first != df_cfg->last;\n}\n\n\/* Enables CTE reception according to provided configuration *\/\nvoid lll_df_conf_cte_rx_enable(uint8_t slot_duration, uint8_t ant_num, uint8_t *ant_ids,\n\t\t\t uint8_t chan_idx);\n","avg_line_length":35.0,"max_line_length":90,"alphanum_fraction":0.7793911007} +{"size":407,"ext":"c","lang":"C","max_stars_count":null,"content":"\/\/ basic_force.c\n\ninherit BOOK;\n\nvoid create()\n{\n\tset_name(\"\u5185\u529f\u5165\u95e8\", ({ \"force book\", \"book\" }));\n\tset_weight(600);\n\tif (clonep())\n\t\tset_default_object(__FILE__);\n\telse {\n\t\tset(\"unit\", \"\u672c\");\n\t\tset(\"long\",\n\"\u5c01\u9762\u4e0a\u5199\u8457\u300c\u5185\u529f\u5165\u95e8\u300d\\n\");\n\t\tset(\"value\", 200);\n\t\tset(\"material\", \"paper\");\n\t\tset(\"skill\", ([\n\t\t\t\"name\": \t\"force\",\n\t\t\t\"exp_required\":\t1000,\n\t\t\t\"jing_cost\":\t20,\n\t\t\t\"difficulty\":\t20,\n\t\t\t\"max_skill\":\t19,\n\t\t]));\n\t}\n}\n","avg_line_length":15.6538461538,"max_line_length":46,"alphanum_fraction":0.5601965602} +{"size":2130,"ext":"c","lang":"C","max_stars_count":9.0,"content":"\/*\n * (c)2012 Michael Duane Rice All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n * Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer. Redistributions in binary\n * form must reproduce the above copyright notice, this list of conditions\n * and the following disclaimer in the documentation and\/or other materials\n * provided with the distribution. Neither the name of the copyright holders\n * nor the names of contributors may be used to endorse or promote products\n * derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n *\/\n\n\/* $Id: sidereal.c 2353 2013-04-19 21:35:53Z swfltek $ *\/\n\n\/*\n This test allows for 1 second error in calculation of sidereal time 136 years after\n the epoch. The 'correct' value is 24004.8 seconds.\n*\/\n\n#include \n#include \n\nint\nmain()\n{\n\n\ttime_t t;\n\tstruct tm calendar;\n\tlong e;\n\n\n\tcalendar.tm_year = 2136 - 1900;\n\tcalendar.tm_mon = 0;\n\tcalendar.tm_mday = 1;\n\tcalendar.tm_hour = 0;\n\tcalendar.tm_min = 0;\n\tcalendar.tm_sec = 0;\n\n\tt = mk_gmtime(&calendar);\n\tt = gm_sidereal(&t);\n\te = t - 24005L;\n\te = labs(e);\n\n\tif ( e > 1 ) return (__LINE__);\n\treturn 0;\n\n}\n","avg_line_length":33.28125,"max_line_length":87,"alphanum_fraction":0.7403755869} +{"size":5987,"ext":"h","lang":"C","max_stars_count":34.0,"content":"\n#ifndef zfa2c586730\n#define zfa2c586730\n#include \"kdrive\/knx\/Config.h\"\n#include \"kdrive\/knx\/telegrams\/formatters\/Formatter.h\"\n#include \n#include \n#include \n#include \nnamespace kdrive{namespace knx{templatestruct Bits{enum{Value=\nz0644e33e40*(0x769+138-0x7eb)};};templatestruct Bytes{enum{\nValue=z892c95fbd3\/(0x17d6+1279-0x1ccd),Offset=z892c95fbd3%(0xec4+5716-0x2510),\nzf715e08e87=Offset==(0x4ab+7940-0x23af)?true:false,};};templatestruct ze973aef068{typedef typename std::tuple_element::type \nz082d8e54fe;enum{Value=z082d8e54fe::z892c95fbd3+ze973aef068::Value};};templatestruct ze973aef068<\n(0x5a3+5272-0x1a3b),Tuple>{typedef typename std::tuple_element<\n(0x1738+1950-0x1ed6),Tuple>::type z082d8e54fe;enum{Value=z082d8e54fe::\nz892c95fbd3};};templatestruct z99fe7e8abf{enum{\nz892c95fbd3=ze973aef068::Value,ByteOffset=Bytes<\nz892c95fbd3>::Value,z6ca52afcb1=Bytes::Offset};};templatestruct z99fe7e8abf<(0x1083+299-0x11ae),Tuple>{enum{z892c95fbd3=\n(0x52+779-0x35d),ByteOffset=(0xb44+5962-0x228e),z6ca52afcb1=(0x1327+2185-0x1bb0)\n};};struct z91680f515b zd49fb66547{static unsigned int read(int z202059467a,int \nz43d31e9636,int z5e1f916d4c,const Buffer&buffer);};struct z91680f515b \nz3e0ba55e2c{static void write(int z202059467a,int z43d31e9636,int z5e1f916d4c,\nBuffer&buffer,unsigned int value);};templateclass zd1e5842927:\npublic AbstractFormatter{private:templatestruct zee7300c16e{enum{\nz892c95fbd3=Bits};};typedef std::tuple,zee7300c16e,\nzee7300c16e,zee7300c16e,zee7300c16e,zee7300c16e,zee7300c16e<\nz87ec4ad8ee>,zee7300c16e,zee7300c16e,zee7300c16e<\nz8fbb5cf7c5> >TypeList;templatestruct Element{typedef typename std::\ntuple_element::type z082d8e54fe;enum{z892c95fbd3=z082d8e54fe::\nz892c95fbd3,z0644e33e40=Bytes::Value,zf715e08e87=Bytes\n::zf715e08e87,z5039e82d36=z892c95fbd3>(0x10ac+485-0x1291)?true:false,ByteOffset=\nz99fe7e8abf::ByteOffset,z6ca52afcb1=z99fe7e8abf\n::z6ca52afcb1};};public:typedef zd1e5842927z3f02cdb302;typedef std::\nshared_ptrPtr;enum{zca14ceedea=std::tuple_size::value,\nz892c95fbd3=ze973aef068::Value,\nz0644e33e40=Bytes::Value,zf715e08e87=Bytes::\nzf715e08e87,z6c5ad13c35=(0x6b2+6194-0x1ec4)};zd1e5842927(){BOOST_STATIC_ASSERT(\nz892c95fbd3!=(0x1554+2807-0x204b));BOOST_STATIC_ASSERT(z0644e33e40!=\n(0x1790+1885-0x1eed));BOOST_STATIC_ASSERT(zf715e08e87==true);BOOST_STATIC_ASSERT\n(sizeof(unsigned int)>=(0x10a5+3190-0x1d17));BOOST_STATIC_ASSERT(zfdaadc77e5<=\nz6c5ad13c35);BOOST_STATIC_ASSERT(T1<=z6c5ad13c35);BOOST_STATIC_ASSERT(T2<=\nz6c5ad13c35);BOOST_STATIC_ASSERT(T3<=z6c5ad13c35);BOOST_STATIC_ASSERT(T4<=\nz6c5ad13c35);BOOST_STATIC_ASSERT(T5<=z6c5ad13c35);BOOST_STATIC_ASSERT(\nz87ec4ad8ee<=z6c5ad13c35);BOOST_STATIC_ASSERT(zc422c570b0<=z6c5ad13c35);\nBOOST_STATIC_ASSERT(z01d7d38b56<=z6c5ad13c35);BOOST_STATIC_ASSERT(z8fbb5cf7c5<=\nz6c5ad13c35);}virtual~zd1e5842927(){}std::size_t size()const override{return \nz0644e33e40;}bool isValid()const override{return true;}templatevoid \nset(unsigned int value){BOOST_STATIC_ASSERT(Element::z5039e82d36);\nz988e257be4[index]=value;}templateunsigned int get()const{\nBOOST_STATIC_ASSERT(Element::z5039e82d36);return z988e257be4[index];}\nprivate:typedef std::arrayValues;templatestruct Reader{inline static void read(Container&container,const \nBuffer&buffer){Reader::read(container,\nbuffer);if(Element::z5039e82d36){const int z202059467a=Element::\nByteOffset;const int z43d31e9636=Element::z6ca52afcb1;const int \nz5e1f916d4c=Element::z892c95fbd3;container[index]=zd49fb66547::read(\nz202059467a,z43d31e9636,z5e1f916d4c,buffer);}}};templatestruct \nReader<(0x3d1+5459-0x1924),Container>{inline static void read(Container&\ncontainer,const Buffer&buffer){if(Element<(0x20a+8499-0x233d)>::z5039e82d36){\ncontainer[(0x17f+6445-0x1aac)]=zd49fb66547::read((0x13b4+2533-0x1d99),\n(0x217b+1420-0x2707),Element<(0x1510+2835-0x2023)>::z892c95fbd3,buffer);}}};\ntemplatestruct Writer{inline static void write(\nContainer&container,Buffer&buffer){Writer::\nwrite(container,buffer);if(Element::z5039e82d36){const int z202059467a=\nElement::ByteOffset;const int z43d31e9636=Element::z6ca52afcb1;\nconst int z5e1f916d4c=Element::z892c95fbd3;const unsigned int value=\ncontainer[index];z3e0ba55e2c::write(z202059467a,z43d31e9636,z5e1f916d4c,buffer,\nvalue);}}};templatestruct Writer<(0x1b+6418-0x192d),Container>{\ninline static void write(Container&container,Buffer&buffer){if(Element<\n(0x1ae5+1593-0x211e)>::z5039e82d36){z3e0ba55e2c::write((0x91c+3843-0x181f),\n(0x117+5451-0x1662),Element<(0x708+5297-0x1bb9)>::z892c95fbd3,buffer,container[\n(0x178+3932-0x10d4)]);}}};std::size_t readImpl(const Buffer&buffer)override{\nReader::read(z988e257be4,buffer);return \nz0644e33e40;}std::size_t writeImpl(Buffer&buffer)override{Writer::write(z988e257be4,buffer);return z0644e33e40;}\nprivate:Values z988e257be4;};}}\n#endif \n\n","avg_line_length":68.0340909091,"max_line_length":80,"alphanum_fraction":0.8147653249} +{"size":25695,"ext":"c","lang":"C","max_stars_count":1.0,"content":"\/*--------------------------------------------------------------------------\n *\n * partitionselection.c\n *\t Provides utility routines to support partition selection.\n *\n * Copyright (c) Pivotal Inc.\n *\n *--------------------------------------------------------------------------\n *\/\n\n#include \"postgres.h\"\n#include \"miscadmin.h\"\n\n#include \"cdb\/partitionselection.h\"\n#include \"cdb\/cdbpartition.h\"\n#include \"executor\/executor.h\"\n#include \"parser\/parse_expr.h\"\n#include \"utils\/memutils.h\"\n\n\/*\n * During attribute re-mapping for heterogeneous partitions, we use\n * this struct to identify which varno's attributes will be re-mapped.\n * Using this struct as a *context* during expression tree walking, we\n * can skip varattnos that do not belong to a given varno.\n *\/\ntypedef struct AttrMapContext\n{\n\tconst AttrNumber *newattno; \/* The mapping table to remap the varattno *\/\n\tIndex varno; \/* Which rte's varattno to re-map *\/\n} AttrMapContext;\n\nstatic bool change_varattnos_varno_walker(Node *node, const AttrMapContext *attrMapCxt);\n\n\/* ----------------------------------------------------------------\n *\t\teval_propagation_expression\n *\n *\t\tEvaluate the propagation expression for the given leaf part Oid\n *\t\tand return the result\n *\n * ----------------------------------------------------------------\n *\/\nstatic int32\neval_propagation_expression(PartitionSelectorState *node, Oid part_oid)\n{\n\tExprState *propagationExprState = node->propagationExprState;\n\n\tExprContext *econtext = node->ps.ps_ExprContext;\n\tResetExprContext(econtext);\n\tbool isNull = false;\n\tExprDoneCond isDone = ExprSingleResult;\n\tDatum result = ExecEvalExpr(propagationExprState, econtext, &isNull, &isDone);\n\treturn DatumGetInt32(result);\n}\n\n\/* ----------------------------------------------------------------\n *\t\tconstruct_partition_constraints_range\n *\n *\t\tconstruct a PartitionConstraints node given a PartitionRule for\n *\t\tpartition by range\n *\n *\t\tcaller is responsible for free the PartitionConstraints generated\n *\n * ----------------------------------------------------------------\n *\/\nstatic PartitionConstraints *\nconstruct_part_constraints_range(PartitionRule *rule)\n{\n\tAssert (NULL != rule);\n\tPartitionConstraints *constraint = makeNode(PartitionConstraints);\n\tAssert (NULL != constraint);\n\tconstraint->pRule = rule;\n\tconstraint->defaultPart = rule->parisdefault;\n\tif (constraint->defaultPart)\n\t{\n\t\treturn constraint;\n\t}\n\n\t\/* retrieve boundary information *\/\n\tif (NULL == rule->parrangestart && NULL == rule->parrangeend)\n\t{\n\t\t\/* partition with only the NULL value *\/\n\t\tconstraint->lowerBound = NULL;\n\t\tconstraint->lbInclusive = true;\n\t\tconstraint->lbOpen = false;\n\t\tconstraint->upperBound = NULL;\n\t\tconstraint->upInclusive = true;\n\t\tconstraint->upOpen = false;\n\n\t\treturn constraint;\n\t}\n\n\tif (NULL == rule->parrangestart)\n\t{\n\t\t\/* open lower bound *\/\n\t\tconstraint->lbOpen = true;\n\t\tconstraint->lowerBound = NULL;\n\t\tconstraint->lbInclusive = false;\n\t}\n\telse\n\t{\n\t\tList *parrangeStart = (List *) rule->parrangestart;\n\t\tAssert (1 == list_length(parrangeStart));\n\t\tNode *lowerBound = (Node *) linitial(parrangeStart);\n\t\tAssert (IsA(lowerBound, Const));\n\t\tconstraint->lowerBound = (Const *) lowerBound;\n\t\tconstraint->lbInclusive = rule->parrangestartincl;\n\t\tconstraint->lbOpen = false;\n\t}\n\n\tif (NULL == rule->parrangeend)\n\t{\n\t\t\/* open upper bound *\/\n\t\tconstraint->upOpen = true;\n\t\tconstraint->upperBound = NULL;\n\t\tconstraint->upInclusive = false;\n\t}\n\telse\n\t{\n\t\tList *parrangeEnd = (List *) rule->parrangeend;\n\t\tAssert (1 == list_length(parrangeEnd));\n\t\tNode *upperBound = (Node *) linitial(parrangeEnd);\n\t\tAssert (IsA(upperBound, Const));\n\t\tconstraint->upperBound = (Const *) upperBound;\n\t\tconstraint->upInclusive = rule->parrangeendincl;\n\t\tconstraint->upOpen = false;\n\t}\n\n\tAssert (!constraint->upOpen || !constraint->lbOpen);\n\treturn constraint;\n}\n\n\/* ----------------------------------------------------------------\n *\t\tconstruct_partition_constraints_list\n *\n *\t\tconstruct a list of PartitionConstraints node given a PartitionRule\n *\t\tfor partition by list\n *\n *\t\tcaller is responsible for free the PartitionConstraintss generated\n *\n * ----------------------------------------------------------------\n *\/\nstatic List *\nconstruct_part_constraints_list(PartitionRule *rule)\n{\n\tList *result = NIL;\n\n\t\/* default part *\/\n\tif (NULL == rule->parlistvalues || rule->parisdefault)\n\t{\n\t\tPartitionConstraints *constraint = makeNode(PartitionConstraints);\n\t\tAssert (NULL != constraint);\n\t\tconstraint->pRule = rule;\n\t\tconstraint->defaultPart = true;\n\t\tresult = lappend(result, constraint);\n\t\treturn result;\n\t}\n\n\tListCell *lc = NULL;\n\tforeach (lc, rule->parlistvalues)\n\t{\n\t\tList *values = (List *) lfirst(lc);\n\t\t\/* make sure it is single-column partition *\/\n\t\tAssert (1 == list_length(values));\n\t\tNode *value = (Node *) lfirst(list_nth_cell(values, 0));\n\t\tAssert (IsA(value, Const));\n\n\t\tPartitionConstraints *constraint = makeNode(PartitionConstraints);\n\t\tAssert (NULL != constraint);\n\t\tconstraint->pRule = rule;\n\t\tconstraint->defaultPart = false;\n\t\tconstraint->lowerBound = (Const *) value;\n\t\tconstraint->lbInclusive = true;\n\t\tconstraint->lbOpen = false;\n\t\tconstraint->upperBound = (Const *) value;\n\t\tconstraint->upInclusive = true;\n\t\tconstraint->upOpen = false;\n\n\t\tresult = lappend(result, constraint);\n\t}\n\treturn result;\n}\n\n\/* ----------------------------------------------------------------\n *\t\tconstruct_partition_constraints\n *\n *\t\tconstruct a list of PartitionConstraints node given a PartitionRule\n *\t\tand its partition type\n *\n *\t\tcaller is responsible for free the PartitionConstraintss generated\n *\n * ----------------------------------------------------------------\n *\/\nstatic List *\nconstruct_part_constraints(PartitionRule *rule, char parkind)\n{\n\tList *result = NIL;\n\tswitch(parkind)\n\t{\n\t\tcase 'r':\n\t\t\tresult = lappend(result, construct_part_constraints_range(rule));\n\t\t\tbreak;\n\t\tcase 'l':\n\t\t\tresult = construct_part_constraints_list(rule);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\telog(ERROR,\"unrecognized partitioning kind '%c'\", parkind);\n\t\t\tbreak;\n\t}\n\treturn result;\n}\n\n\/* ----------------------------------------------------------------\n *\t\teval_part_qual\n *\n *\t\tEvaluate a qualification expression that consists of\n *\t\tPartDefaultExpr, PartBoundExpr, PartBoundInclusionExpr, PartBoundOpenExpr\n *\n *\t\tReturn true is passed, otherwise false.\n *\n * ----------------------------------------------------------------\n *\/\nstatic bool\neval_part_qual(ExprState *exprstate, PartitionSelectorState *node, TupleTableSlot *inputTuple)\n{\n\t\/* evaluate generalPredicate *\/\n\tExprContext *econtext = node->ps.ps_ExprContext;\n\tResetExprContext(econtext);\n\tecontext->ecxt_outertuple = inputTuple;\n\tecontext->ecxt_scantuple = inputTuple;\n\n\tList *qualList = list_make1(exprstate);\n\n\treturn ExecQual(qualList, econtext, false \/* result is not for null *\/);\n}\n\n\/* ----------------------------------------------------------------\n *\t\tpartition_selection\n *\n *\t\tIt finds a child PartitionRule for a given parent partitionNode, which\n *\t\tsatisfies with the given partition key value.\n *\n *\t\tIf no such a child partitionRule is found, return NULL.\n *\n *\t\tInput parameters:\n *\t\tpn: parent PartitionNode\n *\t\taccessMethods: PartitionAccessMethods\n *\t\troot_oid: root table Oid\n *\t\tvalue: partition key value\n *\t\texprTypid: type of the expression\n *\n * ----------------------------------------------------------------\n *\/\nstatic PartitionRule*\npartition_selection(PartitionNode *pn, PartitionAccessMethods *accessMethods, Oid root_oid, Datum value, Oid exprTypid, bool isNull)\n{\n\tAssert (NULL != pn);\n\tAssert (NULL != accessMethods);\n\tPartition *part = pn->part;\n\n\tAssert (1 == part->parnatts);\n\tAttrNumber partAttno = part->paratts[0];\n\tAssert (0 < partAttno);\n\n\tRelation rel = relation_open(root_oid, NoLock);\n\tTupleDesc tupDesc = RelationGetDescr(rel);\n\tAssert(tupDesc->natts >= partAttno);\n\n\tDatum *values = NULL;\n\tbool *isnull = NULL;\n\tcreateValueArrays(partAttno, &values, &isnull);\n\n\tisnull[partAttno - 1] = isNull;\n\tvalues[partAttno - 1] = value;\n\n\tPartitionRule *result = get_next_level_matched_partition(pn, values, isnull, tupDesc, accessMethods, exprTypid);\n\n\tfreeValueArrays(values, isnull);\n\trelation_close(rel, NoLock);\n\n\treturn result;\n}\n\n\/* ----------------------------------------------------------------\n *\t\tpartition_constraints_range\n *\n *\t\tReturns a list of PartitionConstraints of all children PartitionRules\n *\t\twith their constraints for a given partition-by-range\n *\t\tPartitionNode\n *\n * ----------------------------------------------------------------\n *\/\nstatic List *\npartition_constraints_range(PartitionNode *pn)\n{\n\tAssert (NULL != pn && 'r' == pn->part->parkind);\n\tList *result = NIL;\n\tListCell *lc;\n\tforeach (lc, pn->rules)\n\t{\n\t\tPartitionRule *rule = (PartitionRule *) lfirst(lc);\n\t\tPartitionConstraints *constraint = construct_part_constraints_range(rule);\n\t\tresult = lappend(result, constraint);\n\t}\n\treturn result;\n}\n\n\/* ----------------------------------------------------------------\n *\t\tpartition_constraints_list\n *\n *\t\tReturns a list of PartitionConstraints of all children PartitionRules\n *\t\twith their constraints for a given partition-by-list\n *\t\tPartitionNode\n *\n *\t\tIt generates one PartitionConstraints for each partition value in one\n *\t\tPartitionRule\n *\n * ----------------------------------------------------------------\n *\/\nstatic List *\npartition_constraints_list(PartitionNode *pn)\n{\n\tAssert (NULL != pn && 'l' == pn->part->parkind);\n\tList *result = NIL;\n\tListCell *lc = NULL;\n\tforeach (lc, pn->rules)\n\t{\n\t\tPartitionRule *rule = (PartitionRule *) lfirst(lc);\n\t\tresult = list_concat(result, construct_part_constraints_list(rule));\n\t}\n\treturn result;\n}\n\n\/* ----------------------------------------------------------------\n *\t\tpartition_constraints\n *\n *\t\tReturns a list of PartitionConstraints of all children PartitionRules\n *\t\twith their constraints for a given parent PartitionNode\n *\n * ----------------------------------------------------------------\n *\/\nstatic List *\npartition_constraints(PartitionNode *pn)\n{\n\tAssert (NULL != pn);\n\tPartition *part = pn->part;\n\tList *result = NIL;\n\tswitch(part->parkind)\n\t{\n\t\tcase 'r':\n\t\t\tresult = partition_constraints_range(pn);\n\t\t\tbreak;\n\t\tcase 'l':\n\t\t\tresult = partition_constraints_list(pn);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\telog(ERROR,\"unrecognized partitioning kind '%c'\",\n\t\t\t\tpart->parkind);\n\t\t\tbreak;\n\t}\n\n\t\/* add default part if exists *\/\n\tif (NULL != pn->default_part)\n\t{\n\t\tPartitionConstraints *constraint = makeNode(PartitionConstraints);\n\t\tconstraint->pRule = pn->default_part;\n\t\tconstraint->defaultPart = true;\n\t\tresult = lappend(result, constraint);\n\t}\n\treturn result;\n}\n\n\/* ----------------------------------------------------------------\n *\t\tpartition_constraints_for_general_predicate\n *\n *\t\tReturn list of PartitionConstraints for the general predicate\n *\t\tof current partition level\n *\n * ----------------------------------------------------------------\n *\/\nstatic List *\npartition_constraints_for_general_predicate(PartitionSelectorState *node, int level,\n\t\t\t\t\t\tTupleTableSlot *inputTuple, PartitionNode *parentNode)\n{\n\tAssert (NULL != node);\n\tAssert (NULL != parentNode);\n\n\tList *partConstraints = partition_constraints(parentNode);\n\tList *result = NIL;\n\tListCell *lc = NULL;\n\tforeach (lc, partConstraints)\n\t{\n\t\tPartitionConstraints *constraints = (PartitionConstraints *) lfirst(lc);\n\t\t\/* We need to register it to allLevelParts to evaluate the current predicate *\/\n\t\tnode->levelPartConstraints[level] = constraints;\n\n\t\t\/* evaluate generalPredicate *\/\n\t\tExprState *exprstate = (ExprState *) lfirst(list_nth_cell(node->levelExprStates, level));\n\t\tif (eval_part_qual(exprstate, node, inputTuple))\n\t\t{\n\t\t\tresult = lappend(result, constraints);\n\t\t}\n\t}\n\t\/* reset allLevelPartConstraints *\/\n\tnode->levelPartConstraints[level] = NULL;\n\n\treturn result;\n}\n\n\/* ----------------------------------------------------------------\n *\t\tpartition_constraints_for_equality_predicate\n *\n *\t\tReturn list of PartitionConstraints for the equality predicate\n *\t\tof current partition level\n *\n * ----------------------------------------------------------------\n *\/\nstatic List *\npartition_constraints_for_equality_predicate(PartitionSelectorState *node, int level,\n\t\t\t\t\t\tTupleTableSlot *inputTuple, PartitionNode *parentNode)\n{\n\tAssert (NULL != node);\n\tAssert (NULL != node->ps.plan);\n\tAssert (NULL != parentNode);\n\tPartitionSelector *ps = (PartitionSelector *) node->ps.plan;\n\tAssert (level < ps->nLevels);\n\n\t\/* evaluate equalityPredicate to get partition identifier value *\/\n\tExprState *exprState = (ExprState *) lfirst(list_nth_cell(node->levelEqExprStates, level));\n\n\tExprContext *econtext = node->ps.ps_ExprContext;\n\tResetExprContext(econtext);\n\tecontext->ecxt_outertuple = inputTuple;\n\tecontext->ecxt_scantuple = inputTuple;\n\n\tbool isNull = false;\n\tExprDoneCond isDone = ExprSingleResult;\n\tDatum value = ExecEvalExpr(exprState, econtext, &isNull, &isDone);\n\n\t\/*\n\t * Compute the type of the expression result. Sometimes this can be different\n\t * than the type of the partition rules (MPP-25707), and we'll need this type\n\t * to choose the correct comparator.\n\t *\/\n\tOid exprTypid = exprType((Node *) exprState->expr);\n\tPartitionRule *partRule = partition_selection(parentNode, node->accessMethods, ps->relid, value, exprTypid, isNull);\n\tif (NULL != partRule)\n\t{\n\t\treturn construct_part_constraints(partRule, parentNode->part->parkind);\n\t}\n\treturn NIL;\n}\n\n\/* ----------------------------------------------------------------\n *\t\tprocessLevel\n *\n *\t\tfind out satisfied PartOids for the given predicates in the\n *\t\tgiven partition level\n *\n *\t\tThe function is recursively called:\n *\t\t1. If we are in the intermediate level, we register the\n *\t\tsatisfied PartOids and continue with the next level\n *\t\t2. If we are in the leaf level, we will propagate satisfied\n *\t\tPartOids.\n *\n *\t\tThe return structure contains the leaf part oids and the ids of the scan\n *\t\toperators to which they should be propagated\n *\n *\t\tInput parameters:\n *\t\tnode: PartitionSelectorState\n *\t\tlevel: the current partition level, starting with 0.\n *\t\tinputTuple: input tuple from outer child for join partition\n *\t\telimination\n *\n * ----------------------------------------------------------------\n *\/\nSelectedParts *\nprocessLevel(PartitionSelectorState *node, int level, TupleTableSlot *inputTuple)\n{\n\tSelectedParts *selparts = makeNode(SelectedParts);\n\tselparts->partOids = NIL;\n\tselparts->scanIds = NIL;\n\n\tAssert (NULL != node->ps.plan);\n\tPartitionSelector *ps = (PartitionSelector *) node->ps.plan;\n\tAssert (level < ps->nLevels);\n\n\t\/* get equality and general predicate for the current level *\/\n\tExpr *equalityPredicate = (Expr *) lfirst(list_nth_cell(ps->levelEqExpressions, level));\n\tExpr *generalPredicate = (Expr *) lfirst(list_nth_cell(ps->levelExpressions, level));\n\n\t\/* get parent PartitionNode if in level 0, it's the root PartitionNode *\/\n\tPartitionNode *parentNode = node->rootPartitionNode;\n\tif (0 != level)\n\t{\n\t\tAssert (NULL != node->levelPartConstraints[level - 1]);\n\t\tparentNode = node->levelPartConstraints[level - 1]->pRule->children;\n\t}\n\n\t\/* list of PartitionConstraints that satisfied the predicates *\/\n\tList *satisfiedPartConstraints = NULL;\n\n\t\/* If equalityPredicate exists *\/\n\tif (NULL != equalityPredicate)\n\t{\n\t\tAssert (NULL == generalPredicate);\n\n\t\tList *partConstraints = partition_constraints_for_equality_predicate(node, level, inputTuple, parentNode);\n\t\tsatisfiedPartConstraints = list_concat(satisfiedPartConstraints, partConstraints);\n\t}\n\t\/* If generalPredicate exists *\/\n\telse if (NULL != generalPredicate)\n\t{\n\t\tList *partConstraints = partition_constraints_for_general_predicate(node, level, inputTuple, parentNode);\n\t\tsatisfiedPartConstraints = list_concat(satisfiedPartConstraints, partConstraints);\n\t}\n\t\/* None of the predicate exists *\/\n\telse\n\t{\n\t\t\/*\n\t\t * Neither equality predicate nor general predicate\n\t\t * exists. Return all the next level PartitionConstraintss.\n\t\t *\/\n\t\tsatisfiedPartConstraints = partition_constraints(parentNode);\n\t}\n\n\t\/* Based on the satisfied PartitionRules, go to next\n\t * level or propagate PartOids if we are in the leaf level\n\t *\/\n\tListCell* lc = NULL;\n\tforeach (lc, satisfiedPartConstraints)\n\t{\n\t\tPartitionConstraints *partConstraint = (PartitionConstraints *) lfirst(lc);\n\t\tnode->levelPartConstraints[level] = partConstraint;\n\t\tbool freeConstraint = true;\n\n\t\t\/* If we already in the leaf level *\/\n\t\tif (level == ps->nLevels - 1)\n\t\t{\n\t\t\tbool shouldPropagate = true;\n\n\t\t\t\/* if residual predicate exists *\/\n\t\t\tif (NULL != ps->residualPredicate)\n\t\t\t{\n\t\t\t\t\/* evaluate residualPredicate *\/\n\t\t\t\tExprState *exprstate = node->residualPredicateExprState;\n\t\t\t\tshouldPropagate = eval_part_qual(exprstate, node, inputTuple);\n\t\t\t}\n\n\t\t\tif (shouldPropagate)\n\t\t\t{\n\t\t\t\tif (NULL != ps->propagationExpression)\n\t\t\t\t{\n\t\t\t\t\tif (!list_member_oid(selparts->partOids, partConstraint->pRule->parchildrelid))\n\t\t\t\t\t{\n\t\t\t\t\t\tselparts->partOids = lappend_oid(selparts->partOids, partConstraint->pRule->parchildrelid);\n\t\t\t\t\t\tint scanId = eval_propagation_expression(node, partConstraint->pRule->parchildrelid);\n\t\t\t\t\t\tselparts->scanIds = lappend_int(selparts->scanIds, scanId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t\/*\n\t\t\t\t\t * We'll need this partConstraint to evaluate the PartOidExpr of the\n\t\t\t\t\t * PartitionSelector operator's target list. Save it in node->acceptedLeafPart.\n\t\t\t\t\t * PartOidExprState.acceptedLeafPart also points to this partConstraint,\n\t\t\t\t\t * so we must save it here (GPSQL-2956).\n\t\t\t\t\t *\/\n\t\t\t\t\t*node->acceptedLeafPart = partConstraint;\n\t\t\t\t\tfreeConstraint = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\/* Recursively call this function for next level's partition elimination *\/\n\t\telse\n\t\t{\n\t\t\tSelectedParts *selpartsChild = processLevel(node, level+1, inputTuple);\n\t\t\tselparts->partOids = list_concat(selparts->partOids, selpartsChild->partOids);\n\t\t\tselparts->scanIds = list_concat(selparts->scanIds, selpartsChild->scanIds);\n\t\t\tpfree(selpartsChild);\n\t\t}\n\n\t\tif (freeConstraint)\n\t\t{\n\t\t\tpfree(partConstraint);\n\t\t}\n\t}\n\n\tlist_free(satisfiedPartConstraints);\n\n\t\/* After finish iteration, reset this level's PartitionConstraints *\/\n\tnode->levelPartConstraints[level] = NULL;\n\n\treturn selparts;\n}\n\n\/* ----------------------------------------------------------------\n *\t\tinitPartitionSelection\n *\n *\t\tInitialize partition selection state information\n *\n * ----------------------------------------------------------------\n *\/\nPartitionSelectorState *\ninitPartitionSelection(bool isRunTime, PartitionSelector *node, EState *estate)\n{\n\tAssertImply (isRunTime, NULL != estate);\n\n\t\/* create and initialize PartitionSelectorState structure *\/\n\tPartitionSelectorState *psstate = makeNode(PartitionSelectorState);\n\tpsstate->ps.plan = (Plan *) node;\n\tpsstate->ps.state = estate;\n\tpsstate->levelPartConstraints = (PartitionConstraints**) palloc0(node->nLevels * sizeof(PartitionConstraints*));\n\n\tif (isRunTime)\n\t{\n\t\t\/* ExprContext initialization *\/\n\t\tExecAssignExprContext(estate, &psstate->ps);\n\t}\n\telse\n\t{\n\t\tExprContext *econtext = makeNode(ExprContext);\n\n\t\tecontext->ecxt_scantuple = NULL;\n\t\tecontext->ecxt_innertuple = NULL;\n\t\tecontext->ecxt_outertuple = NULL;\n\t\tecontext->ecxt_per_query_memory = 0;\n\t\tecontext->ecxt_per_tuple_memory = AllocSetContextCreate\n\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\tNULL \/*parent *\/,\n\t\t\t\t\t\t\t\t\t\t\t\"ExprContext\",\n\t\t\t\t\t\t\t\t\t\t\tALLOCSET_DEFAULT_MINSIZE,\n\t\t\t\t\t\t\t\t\t\t\tALLOCSET_DEFAULT_INITSIZE,\n\t\t\t\t\t\t\t\t\t\t\tALLOCSET_DEFAULT_MAXSIZE\n\t\t\t\t\t\t\t\t\t\t\t);\n\n\t\tecontext->ecxt_param_exec_vals = NULL;\n\t\tecontext->ecxt_param_list_info = NULL;\n\t\tecontext->ecxt_aggvalues = NULL;\n\t\tecontext->ecxt_aggnulls = NULL;\n\t\tecontext->caseValue_datum = (Datum) 0;\n\t\tecontext->caseValue_isNull = true;\n\t\tecontext->domainValue_datum = (Datum) 0;\n\t\tecontext->domainValue_isNull = true;\n\t\tecontext->ecxt_estate = NULL;\n\t\tecontext->ecxt_callbacks = NULL;\n\n\t\tpsstate->ps.ps_ExprContext = econtext;\n\t}\n\n\t\/* initialize ExprState for evaluating expressions *\/\n\tListCell *lc = NULL;\n\tforeach (lc, node->levelEqExpressions)\n\t{\n\t\tExpr *eqExpr = (Expr *) lfirst(lc);\n\t\tpsstate->levelEqExprStates = lappend(psstate->levelEqExprStates,\n\t\t\t\t\t\t\t\tExecInitExpr(eqExpr, (PlanState *) psstate));\n\t}\n\n\tforeach (lc, node->levelExpressions)\n\t{\n\t\tExpr *generalExpr = (Expr *) lfirst(lc);\n\t\tpsstate->levelExprStates = lappend(psstate->levelExprStates,\n\t\t\t\t\t\t\t\tExecInitExpr(generalExpr, (PlanState *) psstate));\n\t}\n\n\tpsstate->acceptedLeafPart = (PartitionConstraints **) palloc0(sizeof(void *));\n\n\tpsstate->residualPredicateExprState = ExecInitExpr((Expr *) node->residualPredicate,\n\t\t\t\t\t\t\t\t\t(PlanState *) psstate);\n\tpsstate->propagationExprState = ExecInitExpr((Expr *) node->propagationExpression,\n\t\t\t\t\t\t\t\t\t(PlanState *) psstate);\n\n\tpsstate->ps.targetlist = (List *) ExecInitExpr((Expr *) node->plan.targetlist,\n\t\t\t\t\t\t\t\t\t(PlanState *) psstate);\n\n\treturn psstate;\n}\n\n\/* ----------------------------------------------------------------\n *\t\tgetPartitionNodeAndAccessMethod\n *\n * \t\tRetrieve PartitionNode and access method from root table\n *\n * ----------------------------------------------------------------\n *\/\nvoid\ngetPartitionNodeAndAccessMethod(Oid rootOid, List *partsMetadata, MemoryContext memoryContext,\n\t\t\t\t\t\tPartitionNode **partsAndRules, PartitionAccessMethods **accessMethods)\n{\n\tAssert(NULL != partsMetadata);\n\tfindPartitionMetadataEntry(partsMetadata, rootOid, partsAndRules, accessMethods);\n\tAssert(NULL != (*partsAndRules));\n\tAssert(NULL != (*accessMethods));\n\t(*accessMethods)->part_cxt = memoryContext;\n}\n\n\/* ----------------------------------------------------------------\n *\t\tstatic_part_selection\n *\n *\t\tStatically select leaf part oids during optimization time\n *\n * ----------------------------------------------------------------\n *\/\nSelectedParts *\nstatic_part_selection(PartitionSelector *ps)\n{\n\tList *partsMetadata = InitializePartsMetadata(ps->relid);\n\tPartitionSelectorState *psstate = initPartitionSelection(false \/*isRunTime*\/, ps, NULL \/*estate*\/);\n\n\tgetPartitionNodeAndAccessMethod\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tps->relid,\n\t\t\t\t\t\t\t\tpartsMetadata,\n\t\t\t\t\t\t\t\tNULL, \/*memoryContext*\/\n\t\t\t\t\t\t\t\t&psstate->rootPartitionNode,\n\t\t\t\t\t\t\t\t&psstate->accessMethods\n\t\t\t\t\t\t\t\t);\n\n\tSelectedParts *selparts = processLevel(psstate, 0 \/* level *\/, NULL \/*inputSlot*\/);\n\n\t\/* cleanup *\/\n\tpfree(psstate->ps.ps_ExprContext);\n\tpfree(psstate);\n\tlist_free_deep(partsMetadata);\n\n\treturn selparts;\n}\n\n\/*\n * Generate a map for change_varattnos_of_a_node from old and new TupleDesc's,\n * matching according to column name. This function returns a NULL pointer (i.e.\n * null map) if no mapping is necessary (i.e., old and new TupleDesc are already\n * aligned).\n *\n * This function, and change_varattnos_of_a_varno below, used to be in\n * tablecmds.c, but were removed in upstream commit 188a0a00. But we still need\n * this for dynamic partition selection in GDPB, so copied them here.\n *\/\nAttrNumber *\nvarattnos_map(TupleDesc old, TupleDesc new)\n{\n\tAttrNumber *attmap;\n\tint\t\t\ti,\n\t\t\t\tj;\n\n\tbool mapRequired = false;\n\n\tattmap = (AttrNumber *) palloc0(sizeof(AttrNumber) * old->natts);\n\tfor (i = 1; i <= old->natts; i++)\n\t{\n\t\tif (old->attrs[i - 1]->attisdropped)\n\t\t\tcontinue;\t\t\t\/* leave the entry as zero *\/\n\n\t\tfor (j = 1; j <= new->natts; j++)\n\t\t{\n\t\t\tif (strcmp(NameStr(old->attrs[i - 1]->attname),\n\t\t\t\t\t NameStr(new->attrs[j - 1]->attname)) == 0)\n\t\t\t{\n\t\t\t\tattmap[i - 1] = j;\n\n\t\t\t\tif (i != j)\n\t\t\t\t{\n\t\t\t\t\tmapRequired = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!mapRequired)\n\t{\n\t\tpfree(attmap);\n\n\t\t\/* No mapping required, so return NULL *\/\n\t\tattmap = NULL;\n\t}\n\n\treturn attmap;\n}\n\n\/*\n * Replace varattno values in an expression tree according to the given\n * map array, that is, varattno N is replaced by newattno[N-1]. It is\n * caller's responsibility to ensure that the array is long enough to\n * define values for all user varattnos present in the tree. System column\n * attnos remain unchanged. For historical reason, we only map varattno of the first\n * range table entry from this method. So, we call the more general\n * change_varattnos_of_a_varno() with varno set to 1\n *\n * Note that the passed node tree is modified in-place!\n *\/\nvoid\nchange_varattnos_of_a_node(Node *node, const AttrNumber *newattno)\n{\n\t\/* Only attempt re-mapping if re-mapping is necessary (i.e., non-null newattno map) *\/\n\tif (newattno)\n\t{\n\t\tchange_varattnos_of_a_varno(node, newattno, 1 \/* varno is hard-coded to 1 (i.e., only first RTE) *\/);\n\t}\n}\n\n\/*\n * Replace varattno values for a given varno RTE index in an expression\n * tree according to the given map array, that is, varattno N is replaced\n * by newattno[N-1]. It is caller's responsibility to ensure that the array\n * is long enough to define values for all user varattnos present in the tree.\n * System column attnos remain unchanged.\n *\n * Note that the passed node tree is modified in-place!\n *\/\nvoid\nchange_varattnos_of_a_varno(Node *node, const AttrNumber *newattno, Index varno)\n{\n\tAttrMapContext attrMapCxt;\n\n\tattrMapCxt.newattno = newattno;\n\tattrMapCxt.varno = varno;\n\n\t(void) change_varattnos_varno_walker(node, &attrMapCxt);\n}\n\n\/*\n * Remaps the varattno of a varattno in a Var node using an attribute map.\n *\/\nstatic bool\nchange_varattnos_varno_walker(Node *node, const AttrMapContext *attrMapCxt)\n{\n\tif (node == NULL)\n\t\treturn false;\n\tif (IsA(node, Var))\n\t{\n\t\tVar\t\t *var = (Var *) node;\n\n\t\tif (var->varlevelsup == 0 && (var->varno == attrMapCxt->varno) &&\n\t\t\tvar->varattno > 0)\n\t\t{\n\t\t\t\/*\n\t\t\t * ??? the following may be a problem when the node is multiply\n\t\t\t * referenced though stringToNode() doesn't create such a node\n\t\t\t * currently.\n\t\t\t *\/\n\t\t\tAssert(attrMapCxt->newattno[var->varattno - 1] > 0);\n\t\t\tvar->varattno = var->varoattno = attrMapCxt->newattno[var->varattno - 1];\n\t\t}\n\t\treturn false;\n\t}\n\treturn expression_tree_walker(node, change_varattnos_varno_walker,\n\t\t\t\t\t\t\t\t (void *) attrMapCxt);\n}\n","avg_line_length":30.2294117647,"max_line_length":132,"alphanum_fraction":0.6618408251} +{"size":2984,"ext":"h","lang":"C","max_stars_count":9.0,"content":"\/*\n * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * \n * Licensed under the Apache License, Version 2.0 (the \"License\").\n * You may not use this file except in compliance with the License.\n * A copy of the License is located at\n * \n * http:\/\/aws.amazon.com\/apache2.0\n * \n * or in the \"license\" file accompanying this file. This file is distributed\n * on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n * express or implied. See the License for the specific language governing\n * permissions and limitations under the License.\n *\/\n\n\n#pragma once\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nnamespace Aws\n{\nnamespace Http\n{\nnamespace Standard\n{\n class StandardHttpResponse;\n}\n\n\/\/Curl implementation of an http client. Right now it is only synchronous.\nclass AWS_CORE_API CurlHttpClient: public HttpClient\n{\npublic:\n\n using Base = HttpClient;\n\n \/\/Creates client, initializes curl handle if it hasn't been created already.\n CurlHttpClient(const Aws::Client::ClientConfiguration& clientConfig);\n \/\/Makes request and receives response synchronously\n AWS_DEPRECATED(\"This funciton in base class has been deprecated\")\n std::shared_ptr MakeRequest(HttpRequest& request, Aws::Utils::RateLimits::RateLimiterInterface* readLimiter = nullptr,\n Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter = nullptr) const override;\n\n \/\/Makes request with shared_ptr typed request and receives response synchronously\n std::shared_ptr MakeRequest(const std::shared_ptr& request, Aws::Utils::RateLimits::RateLimiterInterface* readLimiter = nullptr,\n Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter = nullptr) const override;\n\n static void InitGlobalState();\n static void CleanupGlobalState();\n\nprivate:\n mutable CurlHandleContainer m_curlHandleContainer;\n bool m_isUsingProxy;\n Aws::String m_proxyUserName;\n Aws::String m_proxyPassword;\n Aws::String m_proxyScheme;\n Aws::String m_proxyHost;\n Aws::String m_proxySSLCertPath;\n Aws::String m_proxySSLCertType;\n Aws::String m_proxySSLKeyPath;\n Aws::String m_proxySSLKeyType;\n Aws::String m_proxyKeyPasswd;\n unsigned m_proxyPort;\n bool m_verifySSL;\n Aws::String m_caPath;\n Aws::String m_caFile;\n bool m_disableExpectHeader;\n bool m_allowRedirects;\n static std::atomic isInit;\n\n void MakeRequestInternal(HttpRequest& request, std::shared_ptr& response,\n Aws::Utils::RateLimits::RateLimiterInterface* readLimiter, \n Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter) const;\n\n\n};\n\nusing PlatformHttpClient = CurlHttpClient;\n\n} \/\/ namespace Http\n} \/\/ namespace Aws\n\n","avg_line_length":33.9090909091,"max_line_length":159,"alphanum_fraction":0.7479892761} +{"size":1731,"ext":"c","lang":"C","max_stars_count":null,"content":"#include \n#include \n#include \"char_operations.h\"\n\nint main()\n{\n char(**funcs)(char);\n funcs = malloc(4 * sizeof(char (*)(char)));\n if(funcs == NULL)\n {\n printf(\"Failed to allocate memory\\n\");\n return 8;\n }\n\n *(funcs + 0) = lower_to_upper;\n *(funcs + 1) = upper_to_lower;\n *(funcs + 2) = space_to_dash;\n *(funcs + 3) = reverse_letter;\n\n int option;\n char *text = malloc(1001 * sizeof(char));\n if (text == NULL)\n {\n printf(\"Failed to allocate memory\\n\");\n free(funcs);\n return 8;\n }\n\n printf(\"Podaj text: \");\n scanf(\"%1000[^\\n]s\", text);\n\n \/\/Clear buff\n while(getchar()!='\\n'){}\n\n printf(\"Podaj opcje do wyknania: \");\n if (scanf(\"%d\", &option) != 1)\n {\n printf(\"Incorrect input\\n\");\n free(text);\n free(funcs);\n return 1;\n }\n if (option < 0 || option > 3)\n {\n printf(\"Incorrect input data\\n\");\n free(text);\n free(funcs);\n return 2;\n }\n\n char *newText;\n\n switch (option)\n {\n case 0:\n newText = letter_modifier(text, lower_to_upper);\n break;\n case 1:\n newText = letter_modifier(text, upper_to_lower);\n break;\n case 2:\n newText = letter_modifier(text, space_to_dash);\n break;\n case 3:\n newText = letter_modifier(text, reverse_letter);\n break;\n default:\n break;\n }\n\n if (newText == NULL)\n {\n printf(\"Failed to allocate memory\\n\");\n free(text);\n free(funcs);\n return 8;\n }\n\n printf(\"%s\", newText);\n\n\n free(text);\n free(newText);\n free(funcs);\n return 0;\n}\n","avg_line_length":19.8965517241,"max_line_length":60,"alphanum_fraction":0.5002888504} +{"size":1953,"ext":"h","lang":"C","max_stars_count":41.0,"content":"\n\/******************************* LICENSE *******************************\n\n * (C) Copyright 1996-2016 ECMWF.\n *\n * This software is licensed under the terms of the Apache Licence Version 2.0\n * which can be obtained at http:\/\/www.apache.org\/licenses\/LICENSE-2.0.\n * In applying this licence, ECMWF does not waive the privileges and immunities\n * granted to it by virtue of its status as an intergovernmental organisation nor\n * does it submit to any jurisdiction.\n\n ******************************* LICENSE *******************************\/\n\n\/*! \\fileNetcdfVectorInterpretorAttributes.h\n \\brief Definition of NetcdfVectorInterpretor Attributes class.\n\n This file is automatically generated.\n Do Not Edit!\n\n Generated: \n*\/\n\n\n#ifndef NetcdfVectorInterpretorWrapper_H\n#define NetcdfVectorInterpretorWrapper_H\n\n#include \"magics.h\"\n#include \"ParameterManager.h\"\n#include \"Factory.h\"\n\n\n\n#include \"NetcdfVectorInterpretor.h\"\n\n\n\n#include \"NetcdfInterpretorWrapper.h\"\n\n\n\n\n\n\n\n\nnamespace magics {\n\nclass MagRequest;\n\n\nclass NetcdfVectorInterpretorWrapper: public NetcdfInterpretorWrapper\n\n{\npublic:\n\/\/ -- constructor\n NetcdfVectorInterpretorWrapper();\n NetcdfVectorInterpretorWrapper(NetcdfVectorInterpretor*);\n\/\/ -- destructor\n virtual ~NetcdfVectorInterpretorWrapper();\n virtual void set(const MagRequest&);\n\n NetcdfVectorInterpretor* me() { return netcdfvectorinterpretor_; }\n\n \tvirtual NetcdfVectorInterpretor* object() { return netcdfvectorinterpretor_; }\n\n\n\tvirtual void object(NetcdfVectorInterpretor* o) {\n\t\t\/\/ Remember to delete the previous object\n\t\tnetcdfvectorinterpretor_ = o;\n\t\tNetcdfInterpretorWrapper::object(o);\n\t\t\n\n\t}\n\n\n\nprotected:\n NetcdfVectorInterpretor* netcdfvectorinterpretor_;\n\n\n\/\/ -- method\n\tvirtual void print(ostream&) const;\n\n\nprivate:\n string tag_;\n\tfriend ostream& operator<<(ostream& s,const NetcdfVectorInterpretorWrapper& p)\n\t{ p.print(s); return s; }\n};\n\n} \/\/ namespace magics\n\n#endif","avg_line_length":21.0,"max_line_length":82,"alphanum_fraction":0.7035330261} +{"size":6987,"ext":"h","lang":"C","max_stars_count":null,"content":"\/*\n * %CopyrightBegin%\n *\n * Copyright Ericsson AB 2005-2011. All Rights Reserved.\n *\n * The contents of this file are subject to the Erlang Public License,\n * Version 1.1, (the \"License\"); you may not use this file except in\n * compliance with the License. You should have received a copy of the\n * Erlang Public License along with this software. If not, it can be\n * retrieved online at http:\/\/www.erlang.org\/.\n *\n * Software distributed under the License is distributed on an \"AS IS\"\n * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See\n * the License for the specific language governing rights and limitations\n * under the License.\n *\n * %CopyrightEnd%\n *\/\n\n\/*\n * Native ethread atomics on PowerPC.\n * Author: Mikael Pettersson.\n *\n * Based on the examples in Appendix E of Motorola's\n * \"Programming Environments Manual For 32-Bit Implementations\n * of the PowerPC Architecture\".\n *\/\n#ifndef ETHREAD_PPC_ATOMIC_H\n#define ETHREAD_PPC_ATOMIC_H\n\n#define ETHR_HAVE_NATIVE_ATOMIC32 1\n#define ETHR_NATIVE_ATOMIC32_IMPL \"ethread\"\n\ntypedef struct {\n volatile ethr_sint32_t counter;\n} ethr_native_atomic32_t;\n\n#if defined(ETHR_TRY_INLINE_FUNCS) || defined(ETHR_ATOMIC_IMPL__)\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADDR 1\n\nstatic ETHR_INLINE ethr_sint32_t *\nethr_native_atomic32_addr(ethr_native_atomic32_t *var)\n{\n return (ethr_sint32_t *) &var->counter;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_SET 1\n\nstatic ETHR_INLINE void\nethr_native_atomic32_set(ethr_native_atomic32_t *var, ethr_sint32_t i)\n{\n var->counter = i;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_READ 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_read(ethr_native_atomic32_t *var)\n{\n return var->counter;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_add_return(ethr_native_atomic32_t *var, ethr_sint32_t incr)\n{\n ethr_sint32_t tmp;\n\n __asm__ __volatile__(\n\t\"1:\\t\"\n\t\"lwarx\t%0,0,%1\\n\\t\"\n\t\"add\t%0,%2,%0\\n\\t\"\n\t\"stwcx.\t%0,0,%1\\n\\t\"\n\t\"bne-\t1b\\n\\t\"\n\t: \"=&r\"(tmp)\n\t: \"r\"(&var->counter), \"r\"(incr)\n\t: \"cc\", \"memory\");\n return tmp;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_ADD_RETURN_ACQB 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_add_return_acqb(ethr_native_atomic32_t *var, ethr_sint32_t incr)\n{\n ethr_sint32_t res;\n res = ethr_native_atomic32_add_return(var, incr);\n __asm__ __volatile(\"isync\\n\\t\" : : : \"memory\");\n return res;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_inc_return(ethr_native_atomic32_t *var)\n{\n ethr_sint32_t tmp;\n\n __asm__ __volatile__(\n\t\"1:\\t\"\n\t\"lwarx\t%0,0,%1\\n\\t\"\n\t\"addic\t%0,%0,1\\n\\t\" \/* due to addi's (rA|0) behaviour *\/\n\t\"stwcx.\t%0,0,%1\\n\\t\"\n\t\"bne-\t1b\\n\\t\"\n\t: \"=&r\"(tmp)\n\t: \"r\"(&var->counter)\n\t: \"cc\", \"memory\");\n return tmp;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_INC_RETURN_ACQB 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_inc_return_acqb(ethr_native_atomic32_t *var)\n{\n ethr_sint32_t res;\n res = ethr_native_atomic32_inc_return(var);\n __asm__ __volatile(\"isync\\n\\t\" : : : \"memory\");\n return res;\n}\n \n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_dec_return(ethr_native_atomic32_t *var)\n{\n ethr_sint32_t tmp;\n\n __asm__ __volatile__(\n\t\"1:\\t\"\n\t\"lwarx\t%0,0,%1\\n\\t\"\n\t\"addic\t%0,%0,-1\\n\\t\"\n\t\"stwcx.\t%0,0,%1\\n\\t\"\n\t\"bne-\t1b\\n\\t\"\n\t: \"=&r\"(tmp)\n\t: \"r\"(&var->counter)\n\t: \"cc\", \"memory\");\n return tmp;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_DEC_RETURN_ACQB 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_dec_return_acqb(ethr_native_atomic32_t *var)\n{\n ethr_sint32_t res;\n res = ethr_native_atomic32_dec_return(var);\n __asm__ __volatile(\"isync\\n\\t\" : : : \"memory\");\n return res;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_and_retold(ethr_native_atomic32_t *var, ethr_sint32_t mask)\n{\n ethr_sint32_t old, new;\n\n __asm__ __volatile__(\n\t\"1:\\t\"\n\t\"lwarx\t%0,0,%2\\n\\t\"\n\t\"and\t%1,%0,%3\\n\\t\"\n\t\"stwcx.\t%1,0,%2\\n\\t\"\n\t\"bne-\t1b\\n\\t\"\n\t: \"=&r\"(old), \"=&r\"(new)\n\t: \"r\"(&var->counter), \"r\"(mask)\n\t: \"cc\", \"memory\");\n return old;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_AND_RETOLD_ACQB 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_and_retold_acqb(ethr_native_atomic32_t *var, ethr_sint32_t mask)\n{\n ethr_sint32_t res;\n res = ethr_native_atomic32_and_retold(var, mask);\n __asm__ __volatile(\"isync\\n\\t\" : : : \"memory\");\n return res;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_or_retold(ethr_native_atomic32_t *var, ethr_sint32_t mask)\n{\n ethr_sint32_t old, new;\n\n __asm__ __volatile__(\n\t\"1:\\t\"\n\t\"lwarx\t%0,0,%2\\n\\t\"\n\t\"or\t%1,%0,%3\\n\\t\"\n\t\"stwcx.\t%1,0,%2\\n\\t\"\n\t\"bne-\t1b\\n\\t\"\n\t: \"=&r\"(old), \"=&r\"(new)\n\t: \"r\"(&var->counter), \"r\"(mask)\n\t: \"cc\", \"memory\");\n return old;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_OR_RETOLD_ACQB 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_or_retold_acqb(ethr_native_atomic32_t *var, ethr_sint32_t mask)\n{\n ethr_sint32_t res;\n res = ethr_native_atomic32_or_retold(var, mask);\n __asm__ __volatile(\"isync\\n\\t\" : : : \"memory\");\n return res;\n}\n\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_xchg(ethr_native_atomic32_t *var, ethr_sint32_t val)\n{\n ethr_sint32_t tmp;\n\n __asm__ __volatile__(\n\t\"1:\\t\"\n\t\"lwarx\t%0,0,%1\\n\\t\"\n\t\"stwcx.\t%2,0,%1\\n\\t\"\n\t\"bne-\t1b\\n\\t\"\n\t: \"=&r\"(tmp)\n\t: \"r\"(&var->counter), \"r\"(val)\n\t: \"cc\", \"memory\");\n return tmp;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_XCHG_ACQB 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_xchg_acqb(ethr_native_atomic32_t *var, ethr_sint32_t val)\n{\n ethr_sint32_t res;\n res = ethr_native_atomic32_xchg(var, val);\n __asm__ __volatile(\"isync\\n\\t\" : : : \"memory\");\n return res;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_cmpxchg(ethr_native_atomic32_t *var,\n\t\t\t ethr_sint32_t new,\n\t\t\t ethr_sint32_t expected)\n{\n ethr_sint32_t old;\n\n __asm__ __volatile__(\n \"1:\\t\"\n \"lwarx\t%0,0,%2\\n\\t\"\n \"cmpw\t0,%0,%3\\n\\t\"\n \"bne\t2f\\n\\t\"\n \"stwcx.\t%1,0,%2\\n\\t\"\n \"bne-\t1b\\n\\t\"\n \"2:\"\n : \"=&r\"(old)\n : \"r\"(new), \"r\"(&var->counter), \"r\"(expected)\n : \"cc\", \"memory\");\n\n return old;\n}\n\n#define ETHR_HAVE_ETHR_NATIVE_ATOMIC32_CMPXCHG_ACQB 1\n\nstatic ETHR_INLINE ethr_sint32_t\nethr_native_atomic32_cmpxchg_acqb(ethr_native_atomic32_t *var,\n\t\t\t\t ethr_sint32_t new,\n\t\t\t\t ethr_sint32_t expected)\n{\n ethr_sint32_t old;\n\n __asm__ __volatile__(\n \"1:\\t\"\n \"lwarx\t%0,0,%2\\n\\t\"\n \"cmpw\t0,%0,%3\\n\\t\"\n \"bne\t2f\\n\\t\"\n \"stwcx.\t%1,0,%2\\n\\t\"\n \"bne-\t1b\\n\\t\"\n \"isync\\n\"\n \"2:\"\n : \"=&r\"(old)\n : \"r\"(new), \"r\"(&var->counter), \"r\"(expected)\n : \"cc\", \"memory\");\n\n return old;\n}\n\n#endif \/* ETHR_TRY_INLINE_FUNCS *\/\n\n#endif \/* ETHREAD_PPC_ATOMIC_H *\/\n","avg_line_length":23.5252525253,"max_line_length":85,"alphanum_fraction":0.7136109918} +{"size":3377,"ext":"h","lang":"C","max_stars_count":9.0,"content":"\/*****************************************************************************\/\r\n\/* SOURCE CONTROL VERSIONS *\/\r\n\/*---------------------------------------------------------------------------*\/\r\n\/* *\/\r\n\/* Version Date Time Author \/ Comment (optional) *\/\r\n\/* *\/\r\n\/* $Log: rxsearch.h,v $\r\n\/* Revision 1.1 2010\/07\/21 17:14:57 richard_wood\r\n\/* Initial checkin of V3.0.0 source code and other resources.\r\n\/* Initial code builds V3.0.0 RC1\r\n\/*\r\n\/* Revision 1.1 2009\/06\/09 13:21:29 richard_wood\r\n\/* *** empty log message ***\r\n\/*\r\n\/* Revision 1.2 2008\/09\/19 14:51:49 richard_wood\r\n\/* Updated for VS 2005\r\n\/*\r\n\/* *\/\r\n\/*****************************************************************************\/\r\n\r\n\/**********************************************************************************\r\nCopyright (c) 2003, Albert M. Choy\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without modification,\r\nare permitted provided that the following conditions are met:\r\n\r\n * Redistributions of source code must retain the above copyright notice,\r\n this list of conditions and the following disclaimer.\r\n * Redistributions in binary form must reproduce the above copyright notice,\r\n this list of conditions and the following disclaimer in the documentation\r\n and\/or other materials provided with the distribution.\r\n * Neither the name of Microplanet, Inc. nor the names of its contributors\r\n may be used to endorse or promote products derived from this software\r\n without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\r\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r\nIN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\r\nINDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r\nBUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r\nOR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r\nWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r\nPOSSIBILITY OF SUCH DAMAGE.\r\n**********************************************************************************\/\r\n\r\n#pragma once\r\n\r\n\/\/forward declaration\r\nclass RegEx;\r\n\r\nclass RxSearch\r\n{\r\npublic:\r\n RxSearch();\r\n ~RxSearch();\r\n\r\n \/\/ returns pointer to result or null\r\n LPCTSTR Search (LPCTSTR buffer, \/\/ null terminated buffer to search\r\n int *resultLen); \/\/ length of result\r\n\r\n \/\/ returns 0 for success\r\n int Compile(LPCTSTR pattern, \/\/ compile pattern for search\r\n BOOL fIgnoreCase = TRUE);\r\n\r\n BOOL HasPattern () { return m_pRegEx ? TRUE : FALSE; }\r\n\r\n \/\/ return 'register' $a thru $z (0-25)\r\n LPCTSTR GetAssignment (int n);\r\n\r\nprivate:\r\n HANDLE m_mutex;\r\n\r\n RegEx * m_pRegEx;\r\n};\r\n","avg_line_length":43.2948717949,"max_line_length":85,"alphanum_fraction":0.5525614451} +{"size":1311,"ext":"h","lang":"C","max_stars_count":null,"content":"#ifndef SLIDER_H\r\n#define SLIDER_H\r\n\r\n#include\r\n#include\r\n#include\r\n#include \r\n#include \"MyToolTip.h\"\r\n\r\n\/\/\u6ed1\u52a8\u6761\r\nclass CMySlider : public QSlider\r\n{\r\n Q_OBJECT\r\npublic:\r\n explicit CMySlider(Qt::Orientation orientation, QWidget* parent =0);\r\n void mouseMoveEvent(QMouseEvent* event);\r\n void mousePressEvent(QMouseEvent * event);\r\n void mouseReleaseEvent(QMouseEvent *event);\r\n bool event(QEvent *event);\r\n bool eventFilter(QObject* target, QEvent * event); \/\/\u4e8b\u4ef6\u8fc7\u6ee4\r\n void leaveEvent(QEvent *event);\r\n void enterEvent(QEvent *event);\r\n\r\nsignals:\r\n void signalPressPosition(qint64 position);\r\n void signalMouseMovePosition(qint64 position);\r\n\r\n\r\npublic slots:\r\n void slotSliderPressed();\r\n void slotSliderReleased();\r\n\r\npublic:\r\n void setToolTipText(const QString toolTip);\r\n CMyToolTip* getToolTip();\r\n void setToolTipVisible(bool bIsToolTipVisible);\r\n bool getToolTipVisible();\r\n\r\nprivate:\r\n bool m_bIsLeftPressDown;\r\n bool m_bIsSliderPressed;\r\n bool m_bIsDragSlider;\r\n\r\n qint64 m_pressedPosition;\r\n qint64 m_LeftPressPointX;\r\n qint64 m_mouseMovePointX;\r\n\r\n CMyToolTip* m_toolTip;\r\n bool m_bIsToolTipVisible;\r\n\r\n};\r\n\r\n#endif \/\/ SLIDER_H\r\n","avg_line_length":24.2777777778,"max_line_length":73,"alphanum_fraction":0.6712433257} +{"size":286,"ext":"h","lang":"C","max_stars_count":1.0,"content":"#ifndef FS_STREAM_H\n#define FS_STREAM_H\n\n#include \n\n\/**\n * \\brief Creates a new stream, and returns the file representation\n * \n * @param length Length of stream buffer\n * \n * @return Pointer to kfile representing the stream\n *\/\nstruct kfile *stream_create(int length);\n\n#endif","avg_line_length":19.0666666667,"max_line_length":67,"alphanum_fraction":0.7307692308} +{"size":1209,"ext":"c","lang":"C","max_stars_count":47.0,"content":"\/* Test for crashing bugs when trying to create too many timers. *\/\n\n#include \n#include \n#include \n#include \n#include \n#include \n\n#if _POSIX_THREADS\n# include \n\nvoid\nthread (union sigval arg)\n{\n puts (\"Timeout\");\n}\n\nint\ndo_test (void)\n{\n int i, res;\n timer_t timerId;\n struct itimerspec itval;\n struct sigevent sigev;\n\n itval.it_interval.tv_sec = 2;\n itval.it_interval.tv_nsec = 0;\n itval.it_value.tv_sec = 2;\n itval.it_value.tv_nsec = 0;\n\n sigev.sigev_notify = SIGEV_THREAD;\n sigev.sigev_signo = SIGRTMIN;\n sigev.sigev_notify_function = thread;\n sigev.sigev_notify_attributes = 0;\n sigev.sigev_value.sival_ptr = (void *) &timerId;\n\n for (i = 0; i < 100; i++)\n {\n printf (\"cnt = %d\\n\", i);\n\n if (timer_create (CLOCK_REALTIME, &sigev, &timerId) < 0)\n\t{\n\t perror (\"timer_create\");\n\t continue;\n\t}\n\n res = timer_settime (timerId, 0, &itval, NULL);\n if (res < 0)\n\tperror (\"timer_settime\");\n\n res = timer_delete (timerId);\n if (res < 0)\n\tperror (\"timer_delete\");\n }\n\n return 0;\n}\n\n# define TEST_FUNCTION do_test ()\n#else\n# define TEST_FUNCTION 0\n#endif\n\n#include \"..\/test-skeleton.c\"\n","avg_line_length":18.3181818182,"max_line_length":68,"alphanum_fraction":0.6542597188} +{"size":371,"ext":"h","lang":"C","max_stars_count":1374.0,"content":"\/\/\n\/\/ HCDOrder.h\n\/\/ 18\u547d\u4ee4\u6a21\u5f0f\n\/\/\n\/\/ Created by yifan on 15\/8\/15.\n\/\/ Copyright (c) 2015\u5e74 \u9ec4\u6210\u90fd. All rights reserved.\n\/\/\n\n#import \n#import \"HCDOrder.h\"\n#import \"HCDWorker.h\"\n\n@interface HCDOrder : NSObject\n\n@property(nonatomic,copy)NSString *orderString;\n\n-(instancetype)initWithOrderString:(NSString *)orderString;\n\/\/\u6267\u884c\u547d\u4ee4\n-(void)executeOrder;\n@end\n","avg_line_length":17.6666666667,"max_line_length":59,"alphanum_fraction":0.7196765499} +{"size":2190,"ext":"c","lang":"C","max_stars_count":33.0,"content":"#include \"user_interface.h\"\n#include \"c_types.h\"\n#include \"c_stdio.h\"\n#include \"mem.h\"\n#include \"osapi.h\"\n\n#include \"user_config.h\"\n#include \"platform\/config.h\"\n#include \"driver\/rfm69.h\"\n#include \"radiohandler.h\"\n#include \"util\/cbuff.h\"\n\n\/* RX Buffer Size - 128 == 2+ packets *\/\n#define RFM_RX_BUFFSIZE 128\n\n\/* TX Buffer Size - 256 == 4+ packets *\/\n#define RFM_TX_BUFFSIZE 256\n\nstatic RFM_Handle rfm_handle_base;\n\nCBUFFOBJ rxBuffObj;\nCBUFF rxBuff[RFM_RX_BUFFSIZE];\n\nCBUFFOBJ txBuffObj;\nCBUFF txBuff[RFM_TX_BUFFSIZE];\n\nbool init_rfm_handler()\n{\n\tint ret = 0;\n\tRFM_Handle * rfm_ptr = &rfm_handle_base;\n\tcbuffInit();\n\n\tmemset(rfm_ptr, 0, sizeof(rfm_handle_base));\n\n\trfm_handle_base.rxBuffNum = cbuffCreate(rxBuff, RFM_RX_BUFFSIZE, &rxBuffObj);\n\trfm_handle_base.txBuffNum = cbuffCreate(txBuff, RFM_TX_BUFFSIZE, &txBuffObj);\n\n\tif (rfm_handle_base.rxBuffNum == 0 || rfm_handle_base.txBuffNum == 0) {\n\t\tNODE_ERR(\"Error creating rfm cbuff(s)\\n\");\n\t} else {\n\t\tNODE_DBG(\"cbuff tx Id=%d, rx = %d\\n\", rfm_handle_base.txBuffNum, rfm_handle_base.rxBuffNum);\n\t}\n\n\tuint8_t thisNodeId, thisNetId;\n\tRFM_CONF_T dummy;\n\tRFM_CONF_T * rfmConfPtr = &dummy;\n\tret = get_config_ptr((void *)rfmConfPtr, rfm_conf_type);\n\tif (ret > 0)\n\t{\n\t\tNODE_DBG(\"Loaded rfm info: Id=%d, netId = %d\\n\", rfmConfPtr->bridgeId, rfmConfPtr->netId);\n\t\tthisNodeId = rfmConfPtr->bridgeId;\n\t\tthisNetId = rfmConfPtr->netId;\n\t} else {\n\t\tthisNodeId = RFM69_NODE_ID;\n\t\tthisNetId = RFM69_NET_ID;\n\t\tNODE_DBG(\"Error loading rfm.conf\\n\");\n\t}\n\n\t\/\/ rfm_handle_base.msgCb = rfm_callback;\n\trfm_handle_base.nodeId = thisNodeId;\n\trfm_handle_base.msgCb = NULL;\n\trfm_handle_base.state = RFM_IDLE;\n\trfm_handle_base.keepAliveTick = 20; \/\/20 ms default\n\trfm_handle_base.sendTimeout = 1000; \/\/1 sec default\n\trfm_handle_base.options = RFM_OUTPUT_ALL;\n\n\tret = rfm69_spi_init();\n if (ret == RFM_SPI_OK)\n {\n NODE_DBG(\"RFM69 SPI Initialized\\n\");\n\t\tret = rfm69_init(rfm_ptr, thisNodeId, thisNetId);\n if (ret == RFM_INIT_OK)\n {\n NODE_DBG(\"RFM69 listening on address %d...\\n\", thisNodeId);\n\t\t\tradioHandlerInit(rfm_ptr);\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tNODE_DBG(\"Error: RFM init returned %d\\n\", ret);\n\treturn false;\n}\n","avg_line_length":26.3855421687,"max_line_length":94,"alphanum_fraction":0.7077625571} +{"size":6461,"ext":"h","lang":"C","max_stars_count":1.0,"content":"\/**\n * \\file\n *\n * \\brief Instance description for DSU\n *\n * Copyright (c) 2013-2014 Atmel Corporation. All rights reserved.\n *\n * \\asf_license_start\n *\n * \\page License\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice,\n * this list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and\/or other materials provided with the distribution.\n *\n * 3. The name of Atmel may not be used to endorse or promote products derived\n * from this software without specific prior written permission.\n *\n * 4. This software may only be redistributed and used in connection with an\n * Atmel microcontroller product.\n *\n * THIS SOFTWARE IS PROVIDED BY ATMEL \"AS IS\" AND ANY EXPRESS OR IMPLIED\n * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\n * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\n * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n *\n * \\asf_license_stop\n *\n *\/\n\n#ifndef _SAMD21_DSU_INSTANCE_\n#define _SAMD21_DSU_INSTANCE_\n\n\/* ========== Register definition for DSU peripheral ========== *\/\n#if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))\n#define REG_DSU_CTRL (0x41002000U) \/**< \\brief (DSU) Control *\/\n#define REG_DSU_STATUSA (0x41002001U) \/**< \\brief (DSU) Status A *\/\n#define REG_DSU_STATUSB (0x41002002U) \/**< \\brief (DSU) Status B *\/\n#define REG_DSU_ADDR (0x41002004U) \/**< \\brief (DSU) Address *\/\n#define REG_DSU_LENGTH (0x41002008U) \/**< \\brief (DSU) Length *\/\n#define REG_DSU_DATA (0x4100200CU) \/**< \\brief (DSU) Data *\/\n#define REG_DSU_DCC0 (0x41002010U) \/**< \\brief (DSU) Debug Communication Channel 0 *\/\n#define REG_DSU_DCC1 (0x41002014U) \/**< \\brief (DSU) Debug Communication Channel 1 *\/\n#define REG_DSU_DID (0x41002018U) \/**< \\brief (DSU) Device Identification *\/\n#define REG_DSU_ENTRY0 (0x41003000U) \/**< \\brief (DSU) Coresight ROM Table Entry 0 *\/\n#define REG_DSU_ENTRY1 (0x41003004U) \/**< \\brief (DSU) Coresight ROM Table Entry 1 *\/\n#define REG_DSU_END (0x41003008U) \/**< \\brief (DSU) Coresight ROM Table End *\/\n#define REG_DSU_MEMTYPE (0x41003FCCU) \/**< \\brief (DSU) Coresight ROM Table Memory Type *\/\n#define REG_DSU_PID4 (0x41003FD0U) \/**< \\brief (DSU) Peripheral Identification 4 *\/\n#define REG_DSU_PID0 (0x41003FE0U) \/**< \\brief (DSU) Peripheral Identification 0 *\/\n#define REG_DSU_PID1 (0x41003FE4U) \/**< \\brief (DSU) Peripheral Identification 1 *\/\n#define REG_DSU_PID2 (0x41003FE8U) \/**< \\brief (DSU) Peripheral Identification 2 *\/\n#define REG_DSU_PID3 (0x41003FECU) \/**< \\brief (DSU) Peripheral Identification 3 *\/\n#define REG_DSU_CID0 (0x41003FF0U) \/**< \\brief (DSU) Component Identification 0 *\/\n#define REG_DSU_CID1 (0x41003FF4U) \/**< \\brief (DSU) Component Identification 1 *\/\n#define REG_DSU_CID2 (0x41003FF8U) \/**< \\brief (DSU) Component Identification 2 *\/\n#define REG_DSU_CID3 (0x41003FFCU) \/**< \\brief (DSU) Component Identification 3 *\/\n#else\n#define REG_DSU_CTRL (*(WoReg8 *)0x41002000U) \/**< \\brief (DSU) Control *\/\n#define REG_DSU_STATUSA (*(RwReg8 *)0x41002001U) \/**< \\brief (DSU) Status A *\/\n#define REG_DSU_STATUSB (*(RoReg8 *)0x41002002U) \/**< \\brief (DSU) Status B *\/\n#define REG_DSU_ADDR (*(RwReg *)0x41002004U) \/**< \\brief (DSU) Address *\/\n#define REG_DSU_LENGTH (*(RwReg *)0x41002008U) \/**< \\brief (DSU) Length *\/\n#define REG_DSU_DATA (*(RwReg *)0x4100200CU) \/**< \\brief (DSU) Data *\/\n#define REG_DSU_DCC0 (*(RwReg *)0x41002010U) \/**< \\brief (DSU) Debug Communication Channel 0 *\/\n#define REG_DSU_DCC1 (*(RwReg *)0x41002014U) \/**< \\brief (DSU) Debug Communication Channel 1 *\/\n#define REG_DSU_DID (*(RoReg *)0x41002018U) \/**< \\brief (DSU) Device Identification *\/\n#define REG_DSU_ENTRY0 (*(RoReg *)0x41003000U) \/**< \\brief (DSU) Coresight ROM Table Entry 0 *\/\n#define REG_DSU_ENTRY1 (*(RoReg *)0x41003004U) \/**< \\brief (DSU) Coresight ROM Table Entry 1 *\/\n#define REG_DSU_END (*(RoReg *)0x41003008U) \/**< \\brief (DSU) Coresight ROM Table End *\/\n#define REG_DSU_MEMTYPE (*(RoReg *)0x41003FCCU) \/**< \\brief (DSU) Coresight ROM Table Memory Type *\/\n#define REG_DSU_PID4 (*(RoReg *)0x41003FD0U) \/**< \\brief (DSU) Peripheral Identification 4 *\/\n#define REG_DSU_PID0 (*(RoReg *)0x41003FE0U) \/**< \\brief (DSU) Peripheral Identification 0 *\/\n#define REG_DSU_PID1 (*(RoReg *)0x41003FE4U) \/**< \\brief (DSU) Peripheral Identification 1 *\/\n#define REG_DSU_PID2 (*(RoReg *)0x41003FE8U) \/**< \\brief (DSU) Peripheral Identification 2 *\/\n#define REG_DSU_PID3 (*(RoReg *)0x41003FECU) \/**< \\brief (DSU) Peripheral Identification 3 *\/\n#define REG_DSU_CID0 (*(RoReg *)0x41003FF0U) \/**< \\brief (DSU) Component Identification 0 *\/\n#define REG_DSU_CID1 (*(RoReg *)0x41003FF4U) \/**< \\brief (DSU) Component Identification 1 *\/\n#define REG_DSU_CID2 (*(RoReg *)0x41003FF8U) \/**< \\brief (DSU) Component Identification 2 *\/\n#define REG_DSU_CID3 (*(RoReg *)0x41003FFCU) \/**< \\brief (DSU) Component Identification 3 *\/\n#endif \/* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) *\/\n\n\/* ========== Instance parameters for DSU peripheral ========== *\/\n#define DSU_CLK_HSB_ID 3\n\n#endif \/* _SAMD21_DSU_INSTANCE_ *\/\n","avg_line_length":64.61,"max_line_length":112,"alphanum_fraction":0.6514471444} +{"size":566,"ext":"h","lang":"C","max_stars_count":null,"content":"\/**\n * VampirTrace\n * http:\/\/www.tu-dresden.de\/zih\/vampirtrace\n *\n * Copyright (c) 2005-2008, ZIH, TU Dresden, Federal Republic of Germany\n *\n * Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing\n * Centre, Federal Republic of Germany\n *\n * See the file COPYING in the package base directory for details\n **\/\n\n#ifndef _VT_COMP_H\n#define _VT_COMP_H\n\n#ifdef __cplusplus\n# define EXTERN extern \"C\"\n#else\n# define EXTERN extern\n#endif\n\n\/* Compiler adapter finalizer *\/\nEXTERN void (*vt_comp_finalize)(void);\n\n#endif\n\n","avg_line_length":20.962962963,"max_line_length":77,"alphanum_fraction":0.6978798587} +{"size":421,"ext":"h","lang":"C","max_stars_count":null,"content":"\/\/\n\/\/ CompetitionEntity+CoreDataClass.h\n\/\/ localsports\n\/\/\n\/\/ Created by Antonio D\u00edaz Arroyo on 31\/1\/18.\n\/\/ Copyright \u00a9 2018 cice. All rights reserved.\n\/\/\n\/\/\n\n#import \n#import \n\n@class ClassificationEntity, MatchEntity;\n\nNS_ASSUME_NONNULL_BEGIN\n\n@interface CompetitionEntity : NSManagedObject\n\n@end\n\nNS_ASSUME_NONNULL_END\n\n#import \"CompetitionEntity+CoreDataProperties.h\"\n","avg_line_length":17.5416666667,"max_line_length":48,"alphanum_fraction":0.7719714964} +{"size":880,"ext":"c","lang":"C","max_stars_count":1.0,"content":"#include \"lwip\/ip.h\"\r\n\r\n\/**\r\n * Source based IPv4 routing hook function. This function works only\r\n * when destination IP is broadcast IP.\r\n *\/\r\nstruct netif * ESP_IRAM_ATTR\r\nip4_route_src(const ip4_addr_t *src, const ip4_addr_t *dest)\r\n{\r\n struct netif *netif = NULL;\r\n\r\n \/* destination IP is broadcast IP? *\/\r\n if ((src != NULL) && (dest->addr == IPADDR_BROADCAST)) {\r\n \/* iterate through netifs *\/\r\n for (netif = netif_list; netif != NULL; netif = netif->next) {\r\n \/* is the netif up, does it have a link and a valid address? *\/\r\n if (netif_is_up(netif) && netif_is_link_up(netif) && !ip4_addr_isany_val(*netif_ip4_addr(netif))) {\r\n \/* source IP matches? *\/\r\n if (ip4_addr_cmp(src, netif_ip4_addr(netif))) {\r\n \/* return netif on which to forward IP packet *\/\r\n return netif;\r\n }\r\n }\r\n }\r\n }\r\n return netif;\r\n}","avg_line_length":32.5925925926,"max_line_length":106,"alphanum_fraction":0.6136363636} +{"size":2896,"ext":"h","lang":"C","max_stars_count":231.0,"content":"\/\/ Copyright (c) 2011 The Chromium Authors. All rights reserved.\n\/\/ Use of this source code is governed by a BSD-style license that can be\n\/\/ found in the LICENSE file.\n\n#ifndef PPAPI_SHARED_IMPL_HOST_RESOURCE_H_\n#define PPAPI_SHARED_IMPL_HOST_RESOURCE_H_\n\n#include \"ppapi\/c\/pp_instance.h\"\n#include \"ppapi\/c\/pp_resource.h\"\n#include \"ppapi\/shared_impl\/ppapi_shared_export.h\"\n\nnamespace ppapi {\n\n\/\/ For \"old\" style resources, PP_Resource values differ on the host and plugin\n\/\/ side. Implementations of those should be careful to use HostResource to\n\/\/ prevent confusion. \"New\" style resources use the same PP_Resource value on\n\/\/ the host and plugin sides, and should not use HostResource.\n\/\/\n\/\/ Old style resources match these file specs:\n\/\/ Proxy: ppapi\/proxy\/ppb_*_proxy.*\n\/\/ Host: webkit\/plugins\/ppapi\/*\n\/\/ New style resources match these file specs:\n\/\/ Proxy: ppapi\/proxy\/*_resource.*\n\/\/ Browser: (content|chrome)\/browser\/renderer_host\/pepper\/pepper_*_host.*\n\/\/ Renderer: (content|chrome)\/renderer\/pepper\/pepper_*_host.*\n\/\/\n\/\/\n\/\/ Represents a PP_Resource sent over the wire. This just wraps a PP_Resource.\n\/\/ The point is to prevent mistakes where the wrong resource value is sent.\n\/\/ Resource values are remapped in the plugin so that it can talk to multiple\n\/\/ hosts. If all values were PP_Resource, it would be easy to forget to do\n\/\/ this transformation.\n\/\/\n\/\/ To get the corresponding plugin PP_Resource for a HostResource, use\n\/\/ PluginResourceTracker::PluginResourceForHostResource().\n\/\/\n\/\/ All HostResources respresent IDs valid in the host.\nclass PPAPI_SHARED_EXPORT HostResource {\n public:\n HostResource();\n\n bool is_null() const {\n return !host_resource_;\n }\n\n \/\/ Some resources are plugin-side only and don't have a corresponding\n \/\/ resource in the host. Yet these resources still need an instance to be\n \/\/ associated with. This function creates a HostResource with the given\n \/\/ instances and a 0 host resource ID for these cases.\n static HostResource MakeInstanceOnly(PP_Instance instance);\n\n \/\/ Sets and retrieves the internal PP_Resource which is valid for the host\n \/\/ (a.k.a. renderer, as opposed to the plugin) process.\n \/\/\n \/\/ DO NOT CALL THESE FUNCTIONS IN THE PLUGIN SIDE OF THE PROXY. The values\n \/\/ will be invalid. See the class comment above.\n void SetHostResource(PP_Instance instance, PP_Resource resource);\n PP_Resource host_resource() const {\n return host_resource_;\n }\n\n PP_Instance instance() const { return instance_; }\n\n \/\/ This object is used in maps so we need to provide this sorting operator.\n bool operator<(const HostResource& other) const {\n if (instance_ != other.instance_)\n return instance_ < other.instance_;\n return host_resource_ < other.host_resource_;\n }\n\n private:\n PP_Instance instance_;\n PP_Resource host_resource_;\n};\n\n} \/\/ namespace ppapi\n\n#endif \/\/ PPAPI_SHARED_IMPL_HOST_RESOURCE_H_\n","avg_line_length":36.6582278481,"max_line_length":78,"alphanum_fraction":0.7534530387} +{"size":932,"ext":"c","lang":"C","max_stars_count":null,"content":"\/**\n * @file\n * @brief\n *\n * @author Anton Kozlov\n * @date 04.06.2014\n *\/\n\n#include \n#include \n#include \n\nvoid task_init(struct task *tsk, int id, struct task *parent,\n\t\tconst char *name, struct thread *main_thread,\n\t\ttask_priority_t priority) {\n\tassert(tsk == task_kernel_task());\n\tassert(id == task_get_id(tsk));\n\tassert(0 == strcmp(name, task_get_name(tsk)));\n\tassert(main_thread == task_get_main(tsk));\n\tassert(TASK_PRIORITY_DEFAULT == task_get_priority(tsk));\n\n\tif (main_thread != NULL) { \/* check for thread.NoThreads module *\/\n\t\tmain_thread->task = tsk;\n\t}\n\n\ttask_resource_init(tsk);\n}\n\nvoid task_do_exit(struct task *task, int status) {\n\tpanic(\"single task %s called\\n\", __func__);\n}\n\nvoid task_start_exit(void) {\n\tpanic(\"single task %s called\\n\", __func__);\n}\n\nvoid __attribute__((noreturn)) task_finish_exit(void) {\n\tpanic(\"single task %s called\\n\", __func__);\n}\n","avg_line_length":23.3,"max_line_length":67,"alphanum_fraction":0.6995708155} +{"size":10087,"ext":"c","lang":"C","max_stars_count":16.0,"content":"#include \n#include \"vicmain_c\"\n#include \"gpdsroutines.h\"\n#include \"mo_include.h\"\n\n#define TEST_ARRAY_LENGTH\t20\n\n\/*\n\nMO_TABLE_READ acceptance and unit test\n\nAuthor:\tJustin McNeill\nDate:\tAugust 1993\n\n*\/\n\nmain44()\n{\nAGGREGATE\tlabel_ptr;\n\nint\t\ti,j,k;\nint\t\tstatus;\nint\t\tlabel_status;\nint\t\tcount;\nint \t\ttotal_records;\nint\t\tlengths[10];\nint\t\titem_number[10];\nint\t\trow_number;\n\nchar\t\tstring[120];\nchar\t\tinvalid_file_name[80];\nchar\t\tlabel_file_name[80], table_file_name[80];\nchar\t\t*value;\nchar\t\tkeywords[TEST_ARRAY_LENGTH][40], \n\t\tobject[TEST_ARRAY_LENGTH][20],\n\t\tvalues[TEST_ARRAY_LENGTH][40];\n\nstruct\tPRODUCTION_TABLE_ENTRY\t*table_ptr;\n\n\/*\n\nGet production table label and table file names.\n\n*\/\n\nstatus = zvp(\"P_LABEL\",label_file_name,&count);\nif ( status != 1 ) \n\t{\n\tzvmessage(\"*** Error in ZVP call for P_LABEL\",\" \");\n\tzabend();\n\t}\n\n\nstatus = zvp(\"P_TABLE\",table_file_name,&count);\nif ( status != 1 ) \n\t{\n\tzvmessage(\"*** Error in ZVP call for P_TABLE\",\" \");\n\tzabend();\n\t}\n\n\nstatus = zvp(\"INVALID\",invalid_file_name,&count);\nif ( status != 1 ) \n\t{\n\tzvmessage(\"*** Error in ZVP call for INVALID\",\" \");\n\tzabend();\n\t}\n\n\/*\n\nGet production table total number of records.\n\n*\/\n\nlabel_ptr = gpds_open_file(label_file_name, &status);\nif ( status < 0 )\n\t{\n\tzvmessage(\"*** Error in GPDS_OPEN_FILE call\",\" \");\n\tzabend();\n\t}\n\nvalue = gpds_get_label_value(label_ptr, \"ROOT\", moFILE_RECORDS, 1, &status);\nif ( status < 0 )\n\t{\n\tzvmessage(\"*** Error in GPDS_GET_LABEL_VALUE call\",\" \");\n\tzabend();\n\t}\ntotal_records = atoi( value );\n\ngpds_close_file(label_ptr);\n\n\nzvmessage(\" \",\" \");\nzvmessage(\"********************************************************\",\" \");\nzvmessage(\" \",\" \");\nzvmessage(\" C Test of mo_table_read\",\" \");\nzvmessage(\" \",\" \");\nzvmessage(\"********************************************************\",\" \");\nzvmessage(\" \",\" \");\n\n\/*\n\nRead consecutive rows from production table.\n\n*\/\n\ntable_ptr = (struct PRODUCTION_TABLE_ENTRY *)malloc\n\t\t(sizeof(struct PRODUCTION_TABLE_ENTRY));\n\nfor ( i=0; ifile_specification_name);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\t(LINES,LINES_SAMPLES) = (%d,%d)\",\n\t\ttable_ptr->lines,table_ptr->lines_samples);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\t(START_LINE,START_SAMPLE) = (%d,%d)\",\n\t\ttable_ptr->start_line,table_ptr->start_sample);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\tFRAME_ID is \\'%s\\' and TILE_ID is \\'%s\\'\",\n\t\ttable_ptr->frame_id,table_ptr->tile_id);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\tMASK_TYPE is \\'%s\\'\",table_ptr->mask_type);\n\tzvmessage(string,\" \");\n\n\t}\n\n\/*\n\nSearch table for first row with 'MASK_TYPE' of 'GENERAL'.\n\n*\/\n\nrow_number = 1;\n\nmo_table_read(label_file_name,table_file_name,table_ptr,\n\t&row_number, \"MASK_TYPE\", \"GENERAL\", 1, &status);\nif ( status < 0 ) \n\t{\n\tzvmessage(\"*** Error in MO_TABLE_READ call\",\" \");\n\tsprintf(string,\"\\tstatus flag is %d\",status);\n\tzvmessage(string,\" \");\n\tzabend();\n\t}\nelse\t\n\t{\n\tzvmessage(\" \",\" \");\n\tzvmessage(\"********************************************************\",\n\t\t\" \");\n\tsprintf(string,\"\\nRecord %d of \\'%s\\':\\n\",\n\t\trow_number,table_file_name);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\tFILE_SPECIFICATION_NAME is \\'%s\\'\",\n\t\ttable_ptr->file_specification_name);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\t(LINES,LINES_SAMPLES) = (%d,%d)\",\n\t\ttable_ptr->lines,table_ptr->lines_samples);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\t(START_LINE,START_SAMPLE) = (%d,%d)\",\n\t\ttable_ptr->start_line,table_ptr->start_sample);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\tFRAME_ID is \\'%s\\' and TILE_ID is \\'%s\\'\",\n\t\ttable_ptr->frame_id,table_ptr->tile_id);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\tMASK_TYPE is \\'%s\\'\",table_ptr->mask_type);\n\tzvmessage(string,\" \");\n\t}\n\/*\n\nSearch table for first row with 'TILE_ID' of '02 of 02'.\n\n*\/\n\nrow_number = 1;\n\nmo_table_read(label_file_name,table_file_name,table_ptr,\n\t&row_number, \"TILE_ID\", \"02 OF 02\", 1, &status);\nif ( status < 0 ) \n\t{\n\tzvmessage(\"*** Error in MO_TABLE_READ call\",\" \");\n\tsprintf(string,\"\\tstatus flag is %d\",status);\n\tzvmessage(string,\" \");\n\tzabend();\n\t}\nelse\t\n\t{\n\tzvmessage(\" \",\" \");\n\tzvmessage(\"********************************************************\",\n\t\t\" \");\n\tsprintf(string,\"\\nRecord %d of \\'%s\\'\\n\",\n\t\trow_number,table_file_name);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\tFILE_SPECIFICATION_NAME is \\'%s\\'\",\n\t\ttable_ptr->file_specification_name);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\t(LINES,LINES_SAMPLES) = (%d,%d)\",\n\t\ttable_ptr->lines,table_ptr->lines_samples);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\t(START_LINE,START_SAMPLE) = (%d,%d)\",\n\t\ttable_ptr->start_line,table_ptr->start_sample);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\tFRAME_ID is \\'%s\\' and TILE_ID is \\'%s\\'\",\n\t\ttable_ptr->frame_id,table_ptr->tile_id);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\tMASK_TYPE is \\'%s\\'\",table_ptr->mask_type);\n\tzvmessage(string,\" \");\n\t}\n\n\/*\n\nSearch table for next row with 'TILE_ID' of '02 of 02' and\ntest for case insensitivity.\n\n*\/\n\nrow_number++;\n\nmo_table_read(label_file_name,table_file_name,table_ptr,\n\t&row_number, \"TILE_iD\", \"02 oF 02\", 1, &status);\nif ( status < 0 ) \n\t{\n\tzvmessage(\"*** Error in MO_TABLE_READ call\",\" \");\n\tsprintf(string,\"\\tstatus flag is %d\",status);\n\tzvmessage(string,\" \");\n\tzabend();\n\t}\nelse\t\n\t{\n\tzvmessage(\" \",\" \");\n\tzvmessage(\"********************************************************\",\n\t\t\" \");\n\tsprintf(string,\"\\nRecord %d of \\'%s\\'\\n\",\n\t\trow_number,table_file_name);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\tFILE_SPECIFICATION_NAME is \\'%s\\'\",\n\t\ttable_ptr->file_specification_name);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\t(LINES,LINES_SAMPLES) = (%d,%d)\",\n\t\ttable_ptr->lines,table_ptr->lines_samples);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\t(START_LINE,START_SAMPLE) = (%d,%d)\",\n\t\ttable_ptr->start_line,table_ptr->start_sample);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\tFRAME_ID is \\'%s\\' and TILE_ID is \\'%s\\'\",\n\t\ttable_ptr->frame_id,table_ptr->tile_id);\n\tzvmessage(string,\" \");\n\tsprintf(string,\"\\tMASK_TYPE is \\'%s\\'\",table_ptr->mask_type);\n\tzvmessage(string,\" \");\n\t}\n\nzvmessage(\" \",\" \");\nzvmessage(\" \",\" \");\nzvmessage(\"********************************************************\",\" \");\nzvmessage(\" \",\" \");\nzvmessage(\"\\tTest of error handling of MO table read function\",\" \");\nzvmessage(\" \",\" \");\nzvmessage(\"********************************************************\",\" \");\nzvmessage(\" \",\" \");\nzvmessage(\"\\tMake call to table read function with \",\" \");\nzvmessage(\"\\ta nonexistent label file. Expect -1 status flag\",\" \");\nzvmessage(\"\\tindicating an error in opening the file.\",\" \");\nzvmessage(\" \",\" \");\n\nrow_number = 1;\n\nmo_table_read(\"NONEXISTENT.LBL\",table_file_name,table_ptr,\n\t&row_number, \"LINES\", \"002050\", 1, &status);\nif ( status < 0 ) \n\t{\n\tzvmessage(\"\\t*** Error in MO table read function.\",\" \");\n\tsprintf(string,\"\\t\\tstatus flag is %d\",status);\n\tzvmessage(string,\" \");\n\t}\n\nzvmessage(\"\\n********************************************************\",\" \");\nzvmessage(\" \",\" \");\nzvmessage(\"\\tMake call to table read function with \",\" \");\nzvmessage(\"\\titem number argument out of range.\",\" \");\nzvmessage(\"\\tExpect succesful read because there are\",\" \");\nzvmessage(\"\\tno keywords with multiple values.\",\" \");\nzvmessage(\" \",\" \");\n\nrow_number = 1;\n\nmo_table_read(label_file_name,table_file_name,table_ptr,\n\t&row_number, \"LINES\", \"002050\", -2, &status);\nif ( status < 0 ) \n\t{\n\tzvmessage(\"\\t*** Error in MO table read function.\",\" \");\n\tsprintf(string,\"\\t\\tstatus flag is %d\",status);\n\tzvmessage(string,\" \");\n\t}\nelse\n\tzvmessage(\"\\tSuccessful MO table read \",\" \");\n\nzvmessage(\"\\n********************************************************\",\" \");\nzvmessage(\" \",\" \");\nzvmessage(\"\\tMake call to table read function with \",\" \");\nzvmessage(\"\\tinput of invalid record type.\",\" \");\nzvmessage(\"\\tExpect a -3 status flag value returned.\",\" \");\nzvmessage(\" \",\" \");\n\nrow_number = 1;\n\nmo_table_read(invalid_file_name,table_file_name,table_ptr,\n\t&row_number, \"LINES\", \"002050\", 1, &status);\nif ( status < 0 ) \n\t{\n\tzvmessage(\"\\t*** Error in MO table read function.\",\" \");\n\tsprintf(string,\"\\t\\tstatus flag is %d\",status);\n\tzvmessage(string,\" \");\n\t}\n\nzvmessage(\"\\n********************************************************\",\" \");\nzvmessage(\" \",\" \");\nzvmessage(\"\\tMake call to table read function with \",\" \");\nzvmessage(\"\\trow_number argument that is negative.\",\" \");\nzvmessage(\"\\tExpect a -4 status flag value returned\",\" \");\nzvmessage(\"\\tindicating failure in search (EOF reached).\",\" \");\nzvmessage(\" \",\" \");\n\nrow_number = -1;\n\nmo_table_read(label_file_name,table_file_name,table_ptr,\n\t&row_number, \"LINES\", \"002050\", 1, &status);\nif ( status < 0 ) \n\t{\n\tzvmessage(\"\\t*** Error in MO table read function.\",\" \");\n\tsprintf(string,\"\\t\\tstatus flag is %d\",status);\n\tzvmessage(string,\" \");\n\t}\n\nzvmessage(\"\\n********************************************************\",\" \");\nzvmessage(\" \",\" \");\nzvmessage(\"\\tMake call to table read function with \",\" \");\nzvmessage(\"\\tkey_value argument that is non-existent..\",\" \");\nzvmessage(\"\\tExpect a -5 status flag value returned\",\" \");\nzvmessage(\"\\tindicating failure in search (EOF reached).\",\" \");\nzvmessage(\" \",\" \");\n\nrow_number = 1;\n\nmo_table_read(label_file_name,table_file_name,table_ptr,\n\t&row_number, \"LINES\", \"002340\", 1, &status);\nif ( status < 0 ) \n\t{\n\tzvmessage(\"\\t*** Error in MO table read function.\",\" \");\n\tsprintf(string,\"\\t\\tstatus flag is %d\",status);\n\tzvmessage(string,\" \");\n\t}\n\nzvmessage(\"\\n***************************************************\\n\",\" \");\nzvmessage(\"\\tEnd of ACCEPTANCE and UNIT test\",\" \");\nzvmessage(\"\\n***************************************************\\n\",\" \");\n}\n","avg_line_length":26.8986666667,"max_line_length":76,"alphanum_fraction":0.6114801229} +{"size":1090,"ext":"h","lang":"C","max_stars_count":null,"content":"Copyright 2016 Gregory Bryant\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\/***********************************************************************\/\n\n\n#ifndef SCOREPARAMETERS_H\n#define SCOREPARAMETERS_H\n\n#include \n#include \n\nnamespace Ui {\n class ScoreParameters;\n}\n\nclass ScoreParameters : public QWidget\n{\n Q_OBJECT\n\npublic:\n explicit ScoreParameters(QWidget *parent = 0);\n ~ScoreParameters();\n QAction *menuAction;\n QMdiSubWindow *mdiSubWindow;\n\nprivate:\n Ui::ScoreParameters *ui;\n\npublic slots:\n void windowMenuAction(void);\n\n};\n\n#endif \/\/ SCOREPARAMETERS_H\n","avg_line_length":23.6956521739,"max_line_length":73,"alphanum_fraction":0.7128440367} +{"size":2727,"ext":"h","lang":"C","max_stars_count":28.0,"content":"\/\/\/ \\file ParamGeneration.h\n\/\/\/\n\/\/\/ \\brief Parameter generation routines for Zerocoin.\n\/\/\/\n\/\/\/ \\author Ian Miers, Christina Garman and Matthew Green\n\/\/\/ \\date June 2013\n\/\/\/\n\/\/\/ \\copyright Copyright 2013 Ian Miers, Christina Garman and Matthew Green\n\/\/\/ \\license This project is released under the MIT license.\n\/\/ Copyright (c) 2017 The PIVX developers\n\/\/ Copyright (c) 2017 The Deviant developers\n\n#ifndef PARAMGENERATION_H_\n#define PARAMGENERATION_H_\n\n#include \"Params.h\"\n\nnamespace libzerocoin {\n\nvoid CalculateParams(ZerocoinParams ¶ms, CBigNum N, std::string aux, uint32_t securityLevel);\nvoid calculateGroupParamLengths(uint32_t maxPLen, uint32_t securityLevel,\n uint32_t *pLen, uint32_t *qLen);\n\n\/\/ Constants\n#define STRING_COMMIT_GROUP \"COIN_COMMITMENT_GROUP\"\n#define STRING_AVC_GROUP \"ACCUMULATED_VALUE_COMMITMENT_GROUP\"\n#define STRING_AVC_ORDER \"ACCUMULATED_VALUE_COMMITMENT_ORDER\"\n#define STRING_AIC_GROUP \"ACCUMULATOR_INTERNAL_COMMITMENT_GROUP\"\n#define STRING_QRNCOMMIT_GROUPG \"ACCUMULATOR_QRN_COMMITMENT_GROUPG\"\n#define STRING_QRNCOMMIT_GROUPH \"ACCUMULATOR_QRN_COMMITMENT_GROUPH\"\n#define ACCUMULATOR_BASE_CONSTANT 31\n#define MAX_PRIMEGEN_ATTEMPTS 10000\n#define MAX_ACCUMGEN_ATTEMPTS 10000\n#define MAX_GENERATOR_ATTEMPTS 10000\n#define NUM_SCHNORRGEN_ATTEMPTS 10000\n\n\/\/ Prototypes\nbool primalityTestByTrialDivision(uint32_t candidate);\nuint256 calculateSeed(CBigNum modulus, std::string auxString, uint32_t securityLevel, std::string groupName);\nuint256 calculateGeneratorSeed(uint256 seed, uint256 pSeed, uint256 qSeed, std::string label, uint32_t index, uint32_t count);\n\nuint256 calculateHash(uint256 input);\nIntegerGroupParams deriveIntegerGroupParams(uint256 seed, uint32_t pLen, uint32_t qLen);\nIntegerGroupParams deriveIntegerGroupFromOrder(CBigNum &groupOrder);\nvoid calculateGroupModulusAndOrder(uint256 seed, uint32_t pLen, uint32_t qLen,\n CBigNum *resultModulus, CBigNum *resultGroupOrder,\n uint256 *resultPseed, uint256 *resultQseed);\nCBigNum calculateGroupGenerator(uint256 seed, uint256 pSeed, uint256 qSeed, CBigNum modulus,\n CBigNum groupOrder, uint32_t index);\nCBigNum generateRandomPrime(uint32_t primeBitLen, uint256 in_seed, uint256 *out_seed,\n uint32_t *prime_gen_counter);\nCBigNum generateIntegerFromSeed(uint32_t numBits, uint256 seed, uint32_t *numIterations);\nbool primalityTestByTrialDivision(uint32_t candidate);\n\n}\/* namespace libzerocoin *\/\n\n#endif \/* PARAMGENERATION_H_ *\/\n","avg_line_length":47.0172413793,"max_line_length":138,"alphanum_fraction":0.7352401907} +{"size":6701,"ext":"h","lang":"C","max_stars_count":575.0,"content":"\/\/ Copyright 2020 The Chromium Authors. All rights reserved.\n\/\/ Use of this source code is governed by a BSD-style license that can be\n\/\/ found in the LICENSE file.\n\n#ifndef CONTENT_BROWSER_PRERENDER_PRERENDER_HOST_REGISTRY_H_\n#define CONTENT_BROWSER_PRERENDER_PRERENDER_HOST_REGISTRY_H_\n\n#include \n\n#include \"base\/callback_forward.h\"\n#include \"base\/observer_list_types.h\"\n#include \"base\/types\/pass_key.h\"\n#include \"content\/browser\/prerender\/prerender_host.h\"\n#include \"content\/browser\/renderer_host\/back_forward_cache_impl.h\"\n#include \"content\/common\/content_export.h\"\n#include \"third_party\/blink\/public\/common\/tokens\/tokens.h\"\n#include \"third_party\/blink\/public\/mojom\/prerender\/prerender.mojom.h\"\n#include \"url\/gurl.h\"\n#include \"url\/origin.h\"\n\nnamespace content {\n\nclass FrameTreeNode;\nclass RenderFrameHostImpl;\nclass WebContentsImpl;\n\n\/\/ Prerender2:\n\/\/ PrerenderHostRegistry creates and retains a prerender host, and reserves it\n\/\/ for NavigationRequest to activate the prerendered page. This is created and\n\/\/ owned by StoragePartitionImpl.\n\/\/ TODO(https:\/\/crbug.com\/1170619): Tie the registry with WebContentsImpl.\n\/\/\n\/\/ The APIs of this class are categorized into two: APIs for triggers and APIs\n\/\/ for activators.\n\/\/\n\/\/ - Triggers (e.g., PrerenderProcessor) can request to create a new prerender\n\/\/ host by CreateAndStartHost() and cancel it by AbandonHost(Async)().\n\/\/ Triggers cannot cancel the host after it's preserved by an activator.\n\/\/ - Activators (i.e., NavigationRequest) can reserve the prerender host on\n\/\/ activation start by ReserveHostToActivate() and activate it by\n\/\/ ActivateReservedHost(). They can abandon the host by\n\/\/ AbandonPreservedHost().\nclass CONTENT_EXPORT PrerenderHostRegistry {\n public:\n using PassKey = base::PassKey;\n\n PrerenderHostRegistry();\n ~PrerenderHostRegistry();\n\n PrerenderHostRegistry(const PrerenderHostRegistry&) = delete;\n PrerenderHostRegistry& operator=(const PrerenderHostRegistry&) = delete;\n PrerenderHostRegistry(PrerenderHostRegistry&&) = delete;\n PrerenderHostRegistry& operator=(PrerenderHostRegistry&&) = delete;\n\n class Observer : public base::CheckedObserver {\n public:\n \/\/ Called once per CreateAndStartHost() call. Does not necessarily\n \/\/ mean a host was created.\n virtual void OnTrigger(const GURL& url) {}\n\n \/\/ Called from the registry's destructor. The observer\n \/\/ should drop any reference to the registry.\n virtual void OnRegistryDestroyed() {}\n };\n\n void AddObserver(Observer* observer);\n void RemoveObserver(Observer* observer);\n\n \/\/ For triggers.\n \/\/ Creates and starts a host. Returns the root frame tree node id of the\n \/\/ prerendered page, which can be used as the id of the host.\n int CreateAndStartHost(blink::mojom::PrerenderAttributesPtr attributes,\n RenderFrameHostImpl& initiator_render_frame_host);\n\n \/\/ For triggers.\n \/\/ Destroys the host registered for `frame_tree_node_id`.\n \/\/ TODO(https:\/\/crbug.com\/1169594): Distinguish two paths that cancel\n \/\/ prerendering. A prerender can be canceled due to the following reasons:\n \/\/ 1. Initiator was no longer interested. Since one prerender may have several\n \/\/ initiators, PrerenderHostRegistry should not destroy a PrerenderHost\n \/\/ instance if one of the initiators is still alive.\n \/\/ 2. Prerendering page did something undesirable. The same behavior always\n \/\/ happens regardless of which caller calls it. So PrerenderHostRegistry\n \/\/ should destroy the PrerenderHost.\n void AbandonHost(int frame_tree_node_id);\n\n \/\/ For triggers.\n \/\/ This is the same with AbandonHost but destroys the prerender host\n \/\/ asynchronously so that the prerendered page itself can cancel prerendering\n \/\/ without concern for self destruction.\n void AbandonHostAsync(int frame_tree_node_id,\n PrerenderHost::FinalStatus final_status);\n\n \/\/ TODO(https:\/\/crbug.com\/1194865): Remove the following method once the\n \/\/ workaround in the call site is removed.\n void AbandonAllHostsForWebContents(const WebContentsImpl& web_contents);\n\n \/\/ For activators.\n \/\/ Reserves the host to activate for a navigation for the given FrameTreeNode.\n \/\/ Returns the root frame tree node id of the prerendered page, which can be\n \/\/ used as the id of the host. Returns RenderFrameHost::kNoFrameTreeNodeId if\n \/\/ it's not found or not ready for activation yet. The caller is responsible\n \/\/ for calling ActivateReservedHost() or AbandonReservedHost() with the id to\n \/\/ release the reserved host.\n int ReserveHostToActivate(const GURL& navigation_url,\n FrameTreeNode& frame_tree_node);\n\n \/\/ For activators.\n \/\/ Activates the host reserved by ReserveHostToActivate().\n \/\/ - For MPArch, this returns the BackForwardCacheImpl::Entry containing the\n \/\/ page that was activated on success, or nullptr on failure.\n \/\/ - For multiple WebContents, this always returns nullptr.\n \/\/ TODO(crbug.com\/1183519): Remove multiple WebContents\n \/\/ implementation after MPArch activation is sufficiently stable.\n \/\/\n \/\/ `current_render_frame_host` is the RenderFrameHostImpl that will be swapped\n \/\/ out and destroyed by the activation.\n std::unique_ptr ActivateReservedHost(\n int frame_tree_node_id,\n RenderFrameHostImpl& current_render_frame_host,\n NavigationRequest& navigation_request);\n\n RenderFrameHostImpl* GetRenderFrameHostForReservedHost(\n int frame_tree_node_id);\n\n \/\/ For activators.\n \/\/ Abandons the host reserved by ReserveHostToActivate().\n void AbandonReservedHost(int frame_tree_node_id);\n\n \/\/ Returns the non-reserved host. Returns nullptr if the frame tree node id\n \/\/ doesn't match any host.\n PrerenderHost* FindHostById(int frame_tree_node_id);\n\n \/\/ Returns the non-reserved host for `prerendering_url`. Returns nullptr if\n \/\/ the URL doesn't match any non-reserved host.\n PrerenderHost* FindHostByUrlForTesting(const GURL& prerendering_url);\n\n private:\n std::unique_ptr AbandonHostInternal(int frame_tree_node_id);\n\n void NotifyTrigger(const GURL& url);\n\n \/\/ Hosts that are not reserved for activation yet.\n \/\/ TODO(https:\/\/crbug.com\/1132746): Expire prerendered contents if they are\n \/\/ not used for a while.\n std::map>\n prerender_host_by_frame_tree_node_id_;\n std::map frame_tree_node_id_by_url_;\n\n \/\/ Hosts that are reserved for activation.\n std::map>\n reserved_prerender_host_by_frame_tree_node_id_;\n\n base::ObserverList observers_;\n};\n\n} \/\/ namespace content\n\n#endif \/\/ CONTENT_BROWSER_PRERENDER_PRERENDER_HOST_REGISTRY_H_\n","avg_line_length":41.88125,"max_line_length":80,"alphanum_fraction":0.7630204447} +{"size":885,"ext":"c","lang":"C","max_stars_count":229.0,"content":"#include \n#include \n#include \n#include \n\nint main()\n{\n char str[] = \"foooo-bar-bazz\";\n\n char* token = strtok(str, \"-\");\n assert(strlen(token) == 5, \"returns the first token\");\n assert(strncmp(token, \"foooo\", strlen(token)) == 0,\n \"returns the first token (2)\");\n\n int i = 0;\n int assertions = 0;\n while (token != NULL) {\n token = strtok(NULL, \"-\");\n i++;\n\n if (i == 1) {\n assert(strncmp(token, \"bar\", strlen(token)) == 0,\n \"returns the second token\");\n assertions++;\n } else if (i == 2) {\n assert(strncmp(token, \"bazz\", strlen(token)) == 0,\n \"returns the third token\");\n assertions++;\n } else if (i == 3) {\n assert(token == NULL, \"returns NULL\");\n assertions++;\n }\n }\n assert(assertions == 3, \"found 2 more tokens and then NULL\");\n\n return test_summary();\n}\n","avg_line_length":23.2894736842,"max_line_length":63,"alphanum_fraction":0.5491525424} +{"size":1310,"ext":"c","lang":"C","max_stars_count":null,"content":"\/\/ Intel 8250 serial port (UART).\n\n#include \"types.h\"\n#include \"defs.h\"\n#include \"param.h\"\n#include \"traps.h\"\n#include \"spinlock.h\"\n#include \"fs.h\"\n#include \"file.h\"\n#include \"mmu.h\"\n#include \"proc.h\"\n#include \"x86.h\"\n\n#define COM1 0x3f8\n\nstatic int uart; \/\/ is there a uart?\n\nvoid\nuartinit(void)\n{\n char *p;\n\n \/\/ Turn off the FIFO\n outb(COM1+2, 0);\n\n \/\/ 9600 baud, 8 data bits, 1 stop bit, parity off.\n outb(COM1+3, 0x80); \/\/ Unlock divisor\n outb(COM1+0, 115200\/9600);\n outb(COM1+1, 0);\n outb(COM1+3, 0x03); \/\/ Lock divisor, 8 data bits.\n outb(COM1+4, 0);\n outb(COM1+1, 0x01); \/\/ Enable receive interrupts.\n\n \/\/ If status is 0xFF, no serial port.\n if(inb(COM1+5) == 0xFF)\n return;\n uart = 1;\n\n \/\/ Acknowledge pre-existing interrupt conditions;\n \/\/ enable interrupts.\n inb(COM1+2);\n inb(COM1+0);\n picenable(IRQ_COM1);\n ioapicenable(IRQ_COM1, 0);\n\n \/\/ Announce that we're here.\n for(p=\"xv6 is running for 081531246\\n\"; *p; p++)\n uartputc(*p);\n}\n\nvoid\nuartputc(int c)\n{\n int i;\n\n if(!uart)\n return;\n for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++)\n microdelay(10);\n outb(COM1+0, c);\n}\n\nstatic int\nuartgetc(void)\n{\n if(!uart)\n return -1;\n if(!(inb(COM1+5) & 0x01))\n return -1;\n return inb(COM1+0);\n}\n\nvoid\nuartintr(void)\n{\n consoleintr(uartgetc);\n}\n","avg_line_length":16.7948717949,"max_line_length":54,"alphanum_fraction":0.6114503817} +{"size":1299,"ext":"h","lang":"C","max_stars_count":1.0,"content":"\/* logging.h\r\n *\r\n * Copyright (C) 2006-2021 wolfSSL Inc.\r\n *\r\n * This file is part of wolfSSL.\r\n *\r\n * wolfSSL is free software; you can redistribute it and\/or modify\r\n * it under the terms of the GNU General Public License as published by\r\n * the Free Software Foundation; either version 2 of the License, or\r\n * (at your option) any later version.\r\n *\r\n * wolfSSL is distributed in the hope that it will be useful,\r\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n * GNU General Public License for more details.\r\n *\r\n * You should have received a copy of the GNU General Public License\r\n * along with this program; if not, write to the Free Software\r\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA\r\n *\/\r\n\r\n\r\n\/* submitted by eof *\/\r\n\r\n\r\n#ifndef CYASSL_LOGGING_H\r\n#define CYASSL_LOGGING_H\r\n\r\n\/* for fips compatibility @wc_fips *\/\r\n#include \r\n#define CYASSL_LEAVE WOLFSSL_LEAVE\r\n#define CYASSL_ERROR WOLFSSL_ERROR\r\n#define CYASSL_ENTER WOLFSSL_ENTER\r\n#define CYASSL_MSG WOLFSSL_MSG\r\n\/* check old macros possibly declared *\/\r\n#if defined(DEBUG_CYASSL) && !defined(DEBUG_WOLFSSL)\r\n #define DEBUG_WOLFSSL\r\n#endif\r\n\r\n#endif \/* CYASSL_LOGGING_H *\/\r\n\r\n","avg_line_length":30.9285714286,"max_line_length":81,"alphanum_fraction":0.7282525019} +{"size":269252,"ext":"h","lang":"C","max_stars_count":null,"content":"\/\/===--- Decl.h - Swift Language Declaration ASTs ---------------*- C++ -*-===\/\/\n\/\/\n\/\/ This source file is part of the Swift.org open source project\n\/\/\n\/\/ Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors\n\/\/ Licensed under Apache License v2.0 with Runtime Library Exception\n\/\/\n\/\/ See https:\/\/swift.org\/LICENSE.txt for license information\n\/\/ See https:\/\/swift.org\/CONTRIBUTORS.txt for the list of Swift project authors\n\/\/\n\/\/===----------------------------------------------------------------------===\/\/\n\/\/\n\/\/ This file defines the Decl class and subclasses.\n\/\/\n\/\/===----------------------------------------------------------------------===\/\/\n\n#ifndef SWIFT_DECL_H\n#define SWIFT_DECL_H\n\n#include \"swift\/AST\/AccessScope.h\"\n#include \"swift\/AST\/Attr.h\"\n#include \"swift\/AST\/CaptureInfo.h\"\n#include \"swift\/AST\/ClangNode.h\"\n#include \"swift\/AST\/ConcreteDeclRef.h\"\n#include \"swift\/AST\/DefaultArgumentKind.h\"\n#include \"swift\/AST\/DiagnosticConsumer.h\"\n#include \"swift\/AST\/DiagnosticEngine.h\"\n#include \"swift\/AST\/GenericParamKey.h\"\n#include \"swift\/AST\/IfConfigClause.h\"\n#include \"swift\/AST\/LayoutConstraint.h\"\n#include \"swift\/AST\/StorageImpl.h\"\n#include \"swift\/AST\/TypeAlignments.h\"\n#include \"swift\/AST\/TypeWalker.h\"\n#include \"swift\/AST\/Types.h\"\n#include \"swift\/AST\/Witness.h\"\n#include \"swift\/Basic\/ArrayRefView.h\"\n#include \"swift\/Basic\/Compiler.h\"\n#include \"swift\/Basic\/Debug.h\"\n#include \"swift\/Basic\/InlineBitfield.h\"\n#include \"swift\/Basic\/NullablePtr.h\"\n#include \"swift\/Basic\/OptionalEnum.h\"\n#include \"swift\/Basic\/Range.h\"\n#include \"swift\/Basic\/Located.h\"\n#include \"llvm\/ADT\/DenseSet.h\"\n#include \"llvm\/Support\/TrailingObjects.h\"\n#include \n\nnamespace swift {\n enum class AccessSemantics : unsigned char;\n class AccessorDecl;\n class ApplyExpr;\n class AvailabilityContext;\n class GenericEnvironment;\n class ArchetypeType;\n class ASTContext;\n struct ASTNode;\n class ASTPrinter;\n class ASTWalker;\n class ConstructorDecl;\n class DestructorDecl;\n class DiagnosticEngine;\n class DynamicSelfType;\n class Type;\n class Expr;\n class DeclRefExpr;\n class ForeignErrorConvention;\n class LiteralExpr;\n class BraceStmt;\n class DeclAttributes;\n class GenericContext;\n class GenericSignature;\n class GenericTypeParamDecl;\n class GenericTypeParamType;\n class ModuleDecl;\n class NamedPattern;\n class EnumCaseDecl;\n class EnumElementDecl;\n class ParameterList;\n class ParameterTypeFlags;\n class Pattern;\n struct PrintOptions;\n struct PropertyWrapperBackingPropertyInfo;\n struct PropertyWrapperTypeInfo;\n struct PropertyWrapperMutability;\n class ProtocolDecl;\n class ProtocolType;\n struct RawComment;\n enum class ResilienceExpansion : unsigned;\n class TypeAliasDecl;\n class Stmt;\n class SubscriptDecl;\n class UnboundGenericType;\n class ValueDecl;\n class VarDecl;\n class OpaqueReturnTypeRepr;\n\n namespace ast_scope {\n class AbstractPatternEntryScope;\n class PatternEntryDeclScope;\n class PatternEntryInitializerScope;\n } \/\/ namespace ast_scope\n\nenum class DeclKind : uint8_t {\n#define DECL(Id, Parent) Id,\n#define LAST_DECL(Id) Last_Decl = Id,\n#define DECL_RANGE(Id, FirstId, LastId) \\\n First_##Id##Decl = FirstId, Last_##Id##Decl = LastId,\n#include \"swift\/AST\/DeclNodes.def\"\n};\nenum : unsigned { NumDeclKindBits =\n countBitsUsed(static_cast(DeclKind::Last_Decl)) };\n\n\n\/\/\/ Fine-grained declaration kind that provides a description of the\n\/\/\/ kind of entity a declaration represents, as it would be used in\n\/\/\/ diagnostics.\n\/\/\/\n\/\/\/ For example, \\c FuncDecl is a single declaration class, but it has\n\/\/\/ several descriptive entries depending on whether it is an\n\/\/\/ operator, global function, local function, method, (observing)\n\/\/\/ accessor, etc.\nenum class DescriptiveDeclKind : uint8_t {\n Import,\n Extension,\n EnumCase,\n TopLevelCode,\n IfConfig,\n PoundDiagnostic,\n PatternBinding,\n Var,\n Param,\n Let,\n Property,\n StaticProperty,\n ClassProperty,\n InfixOperator,\n PrefixOperator,\n PostfixOperator,\n PrecedenceGroup,\n TypeAlias,\n GenericTypeParam,\n AssociatedType,\n Type,\n Enum,\n Struct,\n Class,\n Protocol,\n GenericEnum,\n GenericStruct,\n GenericClass,\n GenericType,\n Subscript,\n StaticSubscript,\n ClassSubscript,\n Constructor,\n Destructor,\n LocalFunction,\n GlobalFunction,\n OperatorFunction,\n Method,\n StaticMethod,\n ClassMethod,\n Getter,\n Setter,\n Addressor,\n MutableAddressor,\n ReadAccessor,\n ModifyAccessor,\n WillSet,\n DidSet,\n EnumElement,\n Module,\n MissingMember,\n Requirement,\n OpaqueResultType,\n OpaqueVarType\n};\n\n\/\/\/ Describes which spelling was used in the source for the 'static' or 'class'\n\/\/\/ keyword.\nenum class StaticSpellingKind : uint8_t {\n None,\n KeywordStatic,\n KeywordClass,\n};\n\n\/\/\/ Keeps track of whether an enum has cases that have associated values.\nenum class AssociatedValueCheck {\n \/\/\/ We have not yet checked.\n Unchecked,\n \/\/\/ The enum contains no cases or all cases contain no associated values.\n NoAssociatedValues,\n \/\/\/ The enum contains at least one case with associated values.\n HasAssociatedValues,\n};\n\n\/\/\/ Diagnostic printing of \\c StaticSpellingKind.\nllvm::raw_ostream &operator<<(llvm::raw_ostream &OS, StaticSpellingKind SSK);\n\n\/\/\/ Encapsulation of the overload signature of a given declaration,\n\/\/\/ which is used to determine uniqueness of a declaration within a\n\/\/\/ given context.\n\/\/\/\n\/\/\/ Two definitions in the same context may not have the same overload\n\/\/\/ signature.\nstruct OverloadSignature {\n \/\/\/ The full name of the declaration.\n DeclName Name;\n\n \/\/\/ The kind of unary operator.\n UnaryOperatorKind UnaryOperator;\n\n \/\/\/ Whether this is an instance member.\n unsigned IsInstanceMember : 1;\n\n \/\/\/ Whether this is a variable.\n unsigned IsVariable : 1;\n\n \/\/\/ Whether this is a function.\n unsigned IsFunction : 1;\n\n \/\/\/ Whether this is a enum element.\n unsigned IsEnumElement : 1;\n\n \/\/\/ Whether this is a nominal type.\n unsigned IsNominal : 1;\n\n \/\/\/ Whether this is a type alias.\n unsigned IsTypeAlias : 1;\n\n \/\/\/ Whether this signature is part of a protocol extension.\n unsigned InProtocolExtension : 1;\n\n \/\/\/ Whether this signature is of a member defined in an extension of a generic\n \/\/\/ type.\n unsigned InExtensionOfGenericType : 1;\n \n \/\/\/ Whether this declaration has an opaque return type.\n unsigned HasOpaqueReturnType : 1;\n\n OverloadSignature()\n : UnaryOperator(UnaryOperatorKind::None), IsInstanceMember(false),\n IsVariable(false), IsFunction(false), InProtocolExtension(false),\n InExtensionOfGenericType(false), HasOpaqueReturnType(false) {}\n};\n\n\/\/\/ Determine whether two overload signatures conflict.\n\/\/\/\n\/\/\/ \\param sig1 The overload signature of the first declaration.\n\/\/\/ \\param sig2 The overload signature of the second declaration.\n\/\/\/ \\param skipProtocolExtensionCheck If \\c true, members of protocol extensions\n\/\/\/ will be allowed to conflict with members of protocol declarations.\nbool conflicting(const OverloadSignature& sig1, const OverloadSignature& sig2,\n bool skipProtocolExtensionCheck = false);\n\n\/\/\/ Determine whether two overload signatures and overload types conflict.\n\/\/\/\n\/\/\/ \\param ctx The AST context.\n\/\/\/ \\param sig1 The overload signature of the first declaration.\n\/\/\/ \\param sig1Type The overload type of the first declaration.\n\/\/\/ \\param sig2 The overload signature of the second declaration.\n\/\/\/ \\param sig2Type The overload type of the second declaration.\n\/\/\/ \\param wouldConflictInSwift5 If non-null, the referenced boolean will be set\n\/\/\/ to \\c true iff the function returns \\c false for this version of\n\/\/\/ Swift, but the given overloads will conflict in Swift 5 mode.\n\/\/\/ \\param skipProtocolExtensionCheck If \\c true, members of protocol extensions\n\/\/\/ will be allowed to conflict with members of protocol declarations.\nbool conflicting(ASTContext &ctx,\n const OverloadSignature& sig1, CanType sig1Type,\n const OverloadSignature& sig2, CanType sig2Type,\n bool *wouldConflictInSwift5 = nullptr,\n bool skipProtocolExtensionCheck = false);\n\n\/\/\/ The kind of artificial main to generate.\nenum class ArtificialMainKind : uint8_t {\n NSApplicationMain,\n UIApplicationMain,\n TypeMain,\n};\n\n\/\/\/ Decl - Base class for all declarations in Swift.\nclass alignas(1 << DeclAlignInBits) Decl {\nprotected:\n union { uint64_t OpaqueBits;\n\n SWIFT_INLINE_BITFIELD_BASE(Decl, bitmax(NumDeclKindBits,8)+1+1+1+1+1,\n Kind : bitmax(NumDeclKindBits,8),\n\n \/\/\/ Whether this declaration is invalid.\n Invalid : 1,\n\n \/\/\/ Whether this declaration was implicitly created, e.g.,\n \/\/\/ an implicit constructor in a struct.\n Implicit : 1,\n\n \/\/\/ Whether this declaration was mapped directly from a Clang AST.\n \/\/\/\n \/\/\/ Use getClangNode() to retrieve the corresponding Clang AST.\n FromClang : 1,\n\n \/\/\/ Whether this declaration was added to the surrounding\n \/\/\/ DeclContext of an active #if config clause.\n EscapedFromIfConfig : 1\n );\n\n SWIFT_INLINE_BITFIELD_FULL(PatternBindingDecl, Decl, 1+2+16,\n \/\/\/ Whether this pattern binding declares static variables.\n IsStatic : 1,\n\n \/\/\/ Whether 'static' or 'class' was used.\n StaticSpelling : 2,\n\n : NumPadBits,\n\n \/\/\/ The number of pattern binding declarations.\n NumPatternEntries : 16\n );\n \n SWIFT_INLINE_BITFIELD_FULL(EnumCaseDecl, Decl, 32,\n : NumPadBits,\n\n \/\/\/ The number of tail-allocated element pointers.\n NumElements : 32\n );\n\n SWIFT_INLINE_BITFIELD(ValueDecl, Decl, 1+1+1,\n AlreadyInLookupTable : 1,\n\n \/\/\/ Whether we have already checked whether this declaration is a \n \/\/\/ redeclaration.\n CheckedRedeclaration : 1,\n\n \/\/\/ Whether the decl can be accessed by swift users; for instance,\n \/\/\/ a.storage for lazy var a is a decl that cannot be accessed.\n IsUserAccessible : 1\n );\n\n SWIFT_INLINE_BITFIELD(AbstractStorageDecl, ValueDecl, 1,\n \/\/\/ Whether this property is a type property (currently unfortunately\n \/\/\/ called 'static').\n IsStatic : 1\n );\n\n SWIFT_INLINE_BITFIELD(VarDecl, AbstractStorageDecl, 1+1+1+1+1+1+1+1,\n \/\/\/ Encodes whether this is a 'let' binding.\n Introducer : 1,\n\n \/\/\/ Whether this declaration was an element of a capture list.\n IsCaptureList : 1,\n \n \/\/\/ Whether this declaration captures the 'self' param under the same name.\n IsSelfParamCapture : 1,\n\n \/\/\/ Whether this vardecl has an initial value bound to it in a way\n \/\/\/ that isn't represented in the AST with an initializer in the pattern\n \/\/\/ binding. This happens in cases like \"for i in ...\", switch cases, etc.\n HasNonPatternBindingInit : 1,\n\n \/\/\/ Whether this is a property used in expressions in the debugger.\n \/\/\/ It is up to the debugger to instruct SIL how to access this variable.\n IsDebuggerVar : 1,\n\n \/\/\/ Whether this is the backing storage for a lazy property.\n IsLazyStorageProperty : 1,\n\n \/\/\/ Whether this is the backing storage for a property wrapper.\n IsPropertyWrapperBackingProperty : 1,\n\n \/\/\/ Whether this is a lazily top-level global variable from the main file.\n IsTopLevelGlobal : 1\n );\n\n SWIFT_INLINE_BITFIELD(ParamDecl, VarDecl, 1+2+NumDefaultArgumentKindBits,\n \/\/\/ Whether we've computed the specifier yet.\n SpecifierComputed : 1,\n\n \/\/\/ The specifier associated with this parameter. This determines\n \/\/\/ the storage semantics of the value e.g. mutability.\n Specifier : 2,\n\n \/\/\/ Information about a symbolic default argument, like #file.\n defaultArgumentKind : NumDefaultArgumentKindBits\n );\n\n SWIFT_INLINE_BITFIELD(SubscriptDecl, VarDecl, 2,\n StaticSpelling : 2\n );\n SWIFT_INLINE_BITFIELD(AbstractFunctionDecl, ValueDecl, 3+8+1+1+1+1+1+1,\n \/\/\/ \\see AbstractFunctionDecl::BodyKind\n BodyKind : 3,\n\n \/\/\/ Import as member status.\n IAMStatus : 8,\n\n \/\/\/ Whether the function has an implicit 'self' parameter.\n HasImplicitSelfDecl : 1,\n\n \/\/\/ Whether we are overridden later.\n Overridden : 1,\n\n \/\/\/ Whether the function body throws.\n Throws : 1,\n\n \/\/\/ Whether this member was synthesized as part of a derived\n \/\/\/ protocol conformance.\n Synthesized : 1,\n\n \/\/\/ Whether this member's body consists of a single expression.\n HasSingleExpressionBody : 1\n );\n\n SWIFT_INLINE_BITFIELD(FuncDecl, AbstractFunctionDecl, 1+1+2+1+1+2+1,\n \/\/\/ Whether we've computed the 'static' flag yet.\n IsStaticComputed : 1,\n\n \/\/\/ Whether this function is a 'static' method.\n IsStatic : 1,\n\n \/\/\/ Whether 'static' or 'class' was used.\n StaticSpelling : 2,\n\n \/\/\/ Whether we are statically dispatched even if overridable\n ForcedStaticDispatch : 1,\n\n \/\/\/ Whether we've computed the 'self' access kind yet.\n SelfAccessComputed : 1,\n\n \/\/\/ Backing bits for 'self' access kind.\n SelfAccess : 2,\n\n \/\/\/ Whether this is a top-level function which should be treated\n \/\/\/ as if it were in local context for the purposes of capture\n \/\/\/ analysis.\n HasTopLevelLocalContextCaptures : 1\n );\n\n SWIFT_INLINE_BITFIELD(AccessorDecl, FuncDecl, 4 + 1 + 1,\n \/\/\/ The kind of accessor this is.\n AccessorKind : 4,\n\n \/\/\/ Whether the accessor is transparent.\n IsTransparent : 1,\n\n \/\/\/ Whether we have computed the above.\n IsTransparentComputed : 1);\n\n SWIFT_INLINE_BITFIELD(ConstructorDecl, AbstractFunctionDecl, 3+1+1,\n \/\/\/ The body initialization kind (+1), or zero if not yet computed.\n \/\/\/\n \/\/\/ This value is cached but is not serialized, because it is a property\n \/\/\/ of the definition of the constructor that is useful only to semantic\n \/\/\/ analysis and SIL generation.\n ComputedBodyInitKind : 3,\n\n \/\/\/ Whether this constructor can fail, by building an Optional type.\n Failable : 1,\n\n \/\/\/ Whether this initializer is a stub placed into a subclass to\n \/\/\/ catch invalid delegations to a designated initializer not\n \/\/\/ overridden by the subclass. A stub will always trap at runtime.\n \/\/\/\n \/\/\/ Initializer stubs can be invoked from Objective-C or through\n \/\/\/ the Objective-C runtime; there is no way to directly express\n \/\/\/ an object construction that will invoke a stub.\n HasStubImplementation : 1\n );\n\n SWIFT_INLINE_BITFIELD_EMPTY(TypeDecl, ValueDecl);\n SWIFT_INLINE_BITFIELD_EMPTY(AbstractTypeParamDecl, TypeDecl);\n\n SWIFT_INLINE_BITFIELD_FULL(GenericTypeParamDecl, AbstractTypeParamDecl, 16+16,\n : NumPadBits,\n\n Depth : 16,\n Index : 16\n );\n\n SWIFT_INLINE_BITFIELD_EMPTY(GenericTypeDecl, TypeDecl);\n\n SWIFT_INLINE_BITFIELD(TypeAliasDecl, GenericTypeDecl, 1+1,\n \/\/\/ Whether the typealias forwards perfectly to its underlying type.\n IsCompatibilityAlias : 1,\n \/\/\/ Whether this was a global typealias synthesized by the debugger.\n IsDebuggerAlias : 1\n );\n\n SWIFT_INLINE_BITFIELD(NominalTypeDecl, GenericTypeDecl, 1+1+1,\n \/\/\/ Whether we have already added implicitly-defined initializers\n \/\/\/ to this declaration.\n AddedImplicitInitializers : 1,\n\n \/\/\/ Whether there is are lazily-loaded conformances for this nominal type.\n HasLazyConformances : 1,\n\n \/\/\/ Whether this nominal type is having its semantic members resolved.\n IsComputingSemanticMembers : 1\n );\n\n SWIFT_INLINE_BITFIELD_FULL(ProtocolDecl, NominalTypeDecl, 1+1+1+1+1+1+1+1+1+8+16,\n \/\/\/ Whether the \\c RequiresClass bit is valid.\n RequiresClassValid : 1,\n\n \/\/\/ Whether this is a class-bounded protocol.\n RequiresClass : 1,\n\n \/\/\/ Whether the \\c ExistentialConformsToSelf bit is valid.\n ExistentialConformsToSelfValid : 1,\n\n \/\/\/ Whether the existential of this protocol conforms to itself.\n ExistentialConformsToSelf : 1,\n\n \/\/\/ Whether the \\c ExistentialTypeSupported bit is valid.\n ExistentialTypeSupportedValid : 1,\n\n \/\/\/ Whether the existential of this protocol can be represented.\n ExistentialTypeSupported : 1,\n\n \/\/\/ True if the protocol has requirements that cannot be satisfied (e.g.\n \/\/\/ because they could not be imported from Objective-C).\n HasMissingRequirements : 1,\n\n \/\/\/ Whether we've computed the inherited protocols list yet.\n InheritedProtocolsValid : 1,\n\n \/\/\/ Whether we have a lazy-loaded requirement signature.\n HasLazyRequirementSignature : 1,\n\n : NumPadBits,\n\n \/\/\/ If this is a compiler-known protocol, this will be a KnownProtocolKind\n \/\/\/ value, plus one. Otherwise, it will be 0.\n KnownProtocol : 8, \/\/ '8' for speed. This only needs 6.\n\n \/\/\/ The number of requirements in the requirement signature.\n NumRequirementsInSignature : 16\n );\n\n SWIFT_INLINE_BITFIELD(ClassDecl, NominalTypeDecl, 1+1+2+1+1+1+1+1+1,\n \/\/\/ Whether this class inherits its superclass's convenience initializers.\n InheritsSuperclassInits : 1,\n ComputedInheritsSuperclassInits : 1,\n\n \/\/\/ \\see ClassDecl::ForeignKind\n RawForeignKind : 2,\n\n \/\/\/ \\see ClassDecl::getEmittedMembers()\n HasForcedEmittedMembers : 1,\n\n HasMissingDesignatedInitializers : 1,\n ComputedHasMissingDesignatedInitializers : 1,\n\n HasMissingVTableEntries : 1,\n ComputedHasMissingVTableEntries : 1,\n\n \/\/\/ Whether instances of this class are incompatible\n \/\/\/ with weak and unowned references.\n IsIncompatibleWithWeakReferences : 1\n );\n\n SWIFT_INLINE_BITFIELD(StructDecl, NominalTypeDecl, 1+1,\n \/\/\/ True if this struct has storage for fields that aren't accessible in\n \/\/\/ Swift.\n HasUnreferenceableStorage : 1,\n \/\/\/ True if this struct is imported from C++ and not trivially copyable.\n IsCxxNotTriviallyCopyable : 1\n );\n \n SWIFT_INLINE_BITFIELD(EnumDecl, NominalTypeDecl, 2+1,\n \/\/\/ True if the enum has cases and at least one case has associated values.\n HasAssociatedValues : 2,\n \/\/\/ True if the enum has at least one case that has some availability\n \/\/\/ attribute. A single bit because it's lazily computed along with the\n \/\/\/ HasAssociatedValues bit.\n HasAnyUnavailableValues : 1\n );\n\n SWIFT_INLINE_BITFIELD(ModuleDecl, TypeDecl, 1+1+1+1+1+1+1+1+1,\n \/\/\/ If the module was or is being compiled with `-enable-testing`.\n TestingEnabled : 1,\n\n \/\/\/ If the module failed to load\n FailedToLoad : 1,\n\n \/\/\/ Whether the module is resilient.\n \/\/\/\n \/\/\/ \\sa ResilienceStrategy\n RawResilienceStrategy : 1,\n\n \/\/\/ Whether all imports have been resolved. Used to detect circular imports.\n HasResolvedImports : 1,\n\n \/\/\/ If the module was or is being compiled with `-enable-private-imports`.\n PrivateImportsEnabled : 1,\n\n \/\/\/ If the module is compiled with `-enable-implicit-dynamic`.\n ImplicitDynamicEnabled : 1,\n\n \/\/\/ Whether the module is a system module.\n IsSystemModule : 1,\n\n \/\/\/ Whether the module was imported from Clang (or, someday, maybe another\n \/\/\/ language).\n IsNonSwiftModule : 1,\n\n \/\/\/ Whether this module is the main module.\n IsMainModule : 1\n );\n\n SWIFT_INLINE_BITFIELD(PrecedenceGroupDecl, Decl, 1+2,\n \/\/\/ Is this an assignment operator?\n IsAssignment : 1,\n\n \/\/\/ The group's associativity. A value of the Associativity enum.\n Associativity : 2\n );\n\n SWIFT_INLINE_BITFIELD(ImportDecl, Decl, 3+8,\n ImportKind : 3,\n\n \/\/\/ The number of elements in this path.\n NumPathElements : 8\n );\n\n SWIFT_INLINE_BITFIELD(ExtensionDecl, Decl, 3+1,\n \/\/\/ An encoding of the default and maximum access level for this extension.\n \/\/\/\n \/\/\/ This is encoded as (1 << (maxAccess-1)) | (1 << (defaultAccess-1)),\n \/\/\/ which works because the maximum is always greater than or equal to the\n \/\/\/ default, and 'private' is never used. 0 represents an uncomputed value.\n DefaultAndMaxAccessLevel : 3,\n\n \/\/\/ Whether there is are lazily-loaded conformances for this extension.\n HasLazyConformances : 1\n );\n\n SWIFT_INLINE_BITFIELD(IfConfigDecl, Decl, 1,\n \/\/\/ Whether this decl is missing its closing '#endif'.\n HadMissingEnd : 1\n );\n\n SWIFT_INLINE_BITFIELD(PoundDiagnosticDecl, Decl, 1+1,\n \/\/\/ `true` if the diagnostic is an error, `false` if it's a warning.\n IsError : 1,\n\n \/\/\/ Whether this diagnostic has already been emitted.\n HasBeenEmitted : 1\n );\n\n SWIFT_INLINE_BITFIELD(MissingMemberDecl, Decl, 1+2,\n NumberOfFieldOffsetVectorEntries : 1,\n NumberOfVTableEntries : 2\n );\n\n } Bits;\n\n \/\/ Storage for the declaration attributes.\n DeclAttributes Attrs;\n \n \/\/\/ The next declaration in the list of declarations within this\n \/\/\/ member context.\n Decl *NextDecl = nullptr;\n \n friend class DeclIterator;\n friend class IterableDeclContext;\n friend class MemberLookupTable;\n\nprivate:\n llvm::PointerUnion Context;\n\n Decl(const Decl&) = delete;\n void operator=(const Decl&) = delete;\n SourceLoc getLocFromSource() const;\n\n struct CachedExternalSourceLocs {\n SourceLoc Loc;\n SourceLoc StartLoc;\n SourceLoc EndLoc;\n SmallVector DocRanges;\n };\n mutable CachedExternalSourceLocs const *CachedSerializedLocs = nullptr;\n const CachedExternalSourceLocs *getSerializedLocs() const;\nprotected:\n\n Decl(DeclKind kind, llvm::PointerUnion context)\n : Context(context) {\n Bits.OpaqueBits = 0;\n Bits.Decl.Kind = unsigned(kind);\n Bits.Decl.Invalid = false;\n Bits.Decl.Implicit = false;\n Bits.Decl.FromClang = false;\n Bits.Decl.EscapedFromIfConfig = false;\n }\n\n \/\/\/ Get the Clang node associated with this declaration.\n ClangNode getClangNodeImpl() const;\n\n \/\/\/ Set the Clang node associated with this declaration.\n void setClangNode(ClangNode Node);\n\n void updateClangNode(ClangNode node) {\n assert(hasClangNode());\n setClangNode(node);\n }\n friend class ClangImporter;\n\n DeclContext *getDeclContextForModule() const;\n\npublic:\n DeclKind getKind() const { return DeclKind(Bits.Decl.Kind); }\n\n \/\/\/ Retrieve the name of the given declaration kind.\n \/\/\/\n \/\/\/ This name should only be used for debugging dumps and other\n \/\/\/ developer aids, and should never be part of a diagnostic or exposed\n \/\/\/ to the user of the compiler in any way.\n static StringRef getKindName(DeclKind K);\n\n \/\/\/ Retrieve the descriptive kind for this declaration.\n DescriptiveDeclKind getDescriptiveKind() const;\n\n \/\/\/ Produce a name for the given descriptive declaration kind, which\n \/\/\/ is suitable for use in diagnostics.\n static StringRef getDescriptiveKindName(DescriptiveDeclKind K);\n\n \/\/\/ Whether swift users should be able to access this decl. For instance,\n \/\/\/ var a.storage for lazy var a is an inaccessible decl. An inaccessible decl\n \/\/\/ has to be implicit; but an implicit decl does not have to be inaccessible,\n \/\/\/ for instance, self.\n bool isUserAccessible() const;\n\n \/\/\/ Determine if the decl can have a comment. If false, a comment will\n \/\/\/ not be serialized.\n bool canHaveComment() const;\n\n LLVM_READONLY\n DeclContext *getDeclContext() const {\n if (auto dc = Context.dyn_cast())\n return dc;\n\n return getDeclContextForModule();\n }\n void setDeclContext(DeclContext *DC);\n\n \/\/\/ Retrieve the innermost declaration context corresponding to this\n \/\/\/ declaration, which will either be the declaration itself (if it's\n \/\/\/ also a declaration context) or its declaration context.\n DeclContext *getInnermostDeclContext() const;\n\n \/\/\/ Retrieve the module in which this declaration resides.\n LLVM_READONLY\n ModuleDecl *getModuleContext() const;\n\n \/\/\/ getASTContext - Return the ASTContext that this decl lives in.\n LLVM_READONLY\n ASTContext &getASTContext() const {\n if (auto dc = Context.dyn_cast())\n return dc->getASTContext();\n\n return *Context.get();\n }\n\n const DeclAttributes &getAttrs() const {\n return Attrs;\n }\n\n DeclAttributes &getAttrs() {\n return Attrs;\n }\n\n \/\/\/ Returns the introduced OS version in the given platform kind specified\n \/\/\/ by @available attribute.\n \/\/\/ This function won't consider the parent context to get the information.\n Optional getIntroducedOSVersion(PlatformKind Kind) const;\n\n \/\/\/ Returns the starting location of the entire declaration.\n SourceLoc getStartLoc() const { return getSourceRange().Start; }\n\n \/\/\/ Returns the end location of the entire declaration.\n SourceLoc getEndLoc() const { return getSourceRange().End; }\n\n \/\/\/ Returns the preferred location when referring to declarations\n \/\/\/ in diagnostics.\n SourceLoc getLoc(bool SerializedOK = true) const;\n\n \/\/\/ Returns the source range of the entire declaration.\n SourceRange getSourceRange() const;\n\n \/\/\/ Returns the source range of the declaration including its attributes.\n SourceRange getSourceRangeIncludingAttrs() const;\n\n SourceLoc TrailingSemiLoc;\n\n \/\/\/ Returns the appropriate kind of entry point to generate for this class,\n \/\/\/ based on its attributes.\n \/\/\/\n \/\/\/ It is an error to call this on a type that does not have either an\n \/\/\/ *ApplicationMain or an main attribute.\n ArtificialMainKind getArtificialMainKind() const;\n\n SWIFT_DEBUG_DUMP;\n SWIFT_DEBUG_DUMPER(dump(const char *filename));\n void dump(raw_ostream &OS, unsigned Indent = 0) const;\n\n \/\/\/ Pretty-print the given declaration.\n \/\/\/\n \/\/\/ \\param OS Output stream to which the declaration will be printed.\n void print(raw_ostream &OS) const;\n void print(raw_ostream &OS, const PrintOptions &Opts) const;\n\n \/\/\/ Pretty-print the given declaration.\n \/\/\/\n \/\/\/ \\param Printer ASTPrinter object.\n \/\/\/\n \/\/\/ \\param Opts Options to control how pretty-printing is performed.\n \/\/\/\n \/\/\/ \\returns true if the declaration was printed or false if the print options\n \/\/\/ required the declaration to be skipped from printing.\n bool print(ASTPrinter &Printer, const PrintOptions &Opts) const;\n\n \/\/\/ Determine whether this declaration should be printed when\n \/\/\/ encountered in its declaration context's list of members.\n bool shouldPrintInContext(const PrintOptions &PO) const;\n\n bool walk(ASTWalker &walker);\n\n \/\/\/ Return whether this declaration has been determined invalid.\n bool isInvalid() const;\n \n \/\/\/ Mark this declaration invalid.\n void setInvalid();\n\n \/\/\/ Determine whether this declaration was implicitly generated by the\n \/\/\/ compiler (rather than explicitly written in source code).\n bool isImplicit() const { return Bits.Decl.Implicit; }\n\n \/\/\/ Mark this declaration as implicit.\n void setImplicit(bool implicit = true) { Bits.Decl.Implicit = implicit; }\n\npublic:\n bool escapedFromIfConfig() const {\n return Bits.Decl.EscapedFromIfConfig;\n }\n\n void setEscapedFromIfConfig(bool Escaped) {\n Bits.Decl.EscapedFromIfConfig = Escaped;\n }\n\n \/\/\/ \\returns the unparsed comment attached to this declaration.\n RawComment getRawComment(bool SerializedOK = false) const;\n\n Optional getGroupName() const;\n\n Optional getSourceFileName() const;\n\n Optional getSourceOrder() const;\n\n \/\/\/ \\returns the brief comment attached to this declaration.\n StringRef getBriefComment() const;\n\n \/\/\/ Returns true if there is a Clang AST node associated\n \/\/\/ with self.\n bool hasClangNode() const {\n return Bits.Decl.FromClang;\n }\n\n \/\/\/ Retrieve the Clang AST node from which this declaration was\n \/\/\/ synthesized, if any.\n LLVM_READONLY\n ClangNode getClangNode() const {\n if (!Bits.Decl.FromClang)\n return ClangNode();\n\n return getClangNodeImpl();\n }\n\n \/\/\/ Retrieve the Clang declaration from which this declaration was\n \/\/\/ synthesized, if any.\n LLVM_READONLY\n const clang::Decl *getClangDecl() const {\n if (!Bits.Decl.FromClang)\n return nullptr;\n\n return getClangNodeImpl().getAsDecl();\n }\n\n \/\/\/ Retrieve the Clang macro from which this declaration was\n \/\/\/ synthesized, if any.\n LLVM_READONLY\n const clang::MacroInfo *getClangMacro() {\n if (!Bits.Decl.FromClang)\n return nullptr;\n\n return getClangNodeImpl().getAsMacro();\n }\n\n \/\/\/ Return the GenericContext if the Decl has one.\n LLVM_READONLY\n const GenericContext *getAsGenericContext() const;\n\n bool hasUnderscoredNaming() const;\n\n bool isPrivateStdlibDecl(bool treatNonBuiltinProtocolsAsPublic = true) const;\n \n \/\/\/ Check if this is a declaration defined at the top level of the Swift module\n bool isStdlibDecl() const;\n\n AvailabilityContext getAvailabilityForLinkage() const;\n\n \/\/\/ Whether this declaration or one of its outer contexts has the\n \/\/\/ @_weakLinked attribute.\n bool isAlwaysWeakImported() const;\n\n \/\/\/ Whether this declaration is weak-imported from the given module,\n \/\/\/ either because of the presence of the @_weakLinked attribute, or\n \/\/\/ because of availability.\n \/\/\/\n \/\/\/ Note that \\p fromModule should either be the \"main module\" or\n \/\/\/ nullptr. (This is because when it is non-null, we query the\n \/\/\/ current deployment target, and not the deployment target that\n \/\/\/ the module was built with.)\n \/\/\/\n \/\/\/ If \\p fromModule is the main module, this returns false when the\n \/\/\/ declaration is part of the main module, or if the declaration is\n \/\/\/ at least as available as the current deployment target.\n \/\/\/\n \/\/\/ If \\p fromModule is null, we instead return true if the\n \/\/\/ declaration is meant to be weak linked with _some_ deployment\n \/\/\/ target; that is, the presence of the @_weakLinked attribute or\n \/\/\/ any kind of availability is enough, irrespective of the current\n \/\/\/ deployment target.\n bool isWeakImported(ModuleDecl *fromModule) const;\n\n \/\/\/ Returns true if the nature of this declaration allows overrides.\n \/\/\/ Note that this does not consider whether it is final or whether\n \/\/\/ the class it's on is final.\n \/\/\/\n \/\/\/ If this returns true, the decl can be safely casted to ValueDecl.\n bool isPotentiallyOverridable() const;\n\n \/\/\/ Returns true if this Decl cannot be seen by any other source file\n bool isPrivateToEnclosingFile() const;\n\n \/\/\/ If an alternative module name is specified for this decl, e.g. using\n \/\/\/ @_originalDefinedIn attribute, this function returns this module name.\n StringRef getAlternateModuleName() const;\n\n \/\/ Is this Decl an SPI? It can be directly marked with @_spi or is defined in\n \/\/ an @_spi context.\n bool isSPI() const;\n\n \/\/ List the SPI groups declared with @_spi or inherited by this decl.\n \/\/\n \/\/ SPI groups are inherited from the parent contexts only if the local decl\n \/\/ doesn't declare any @_spi.\n ArrayRef getSPIGroups() const;\n\n \/\/\/ Emit a diagnostic tied to this declaration.\n template\n InFlightDiagnostic diagnose(\n Diag ID,\n typename detail::PassArgument::type... Args) const {\n return getDiags().diagnose(this, ID, std::move(Args)...);\n }\n\n \/\/\/ Retrieve the diagnostic engine for diagnostics emission.\n LLVM_READONLY\n DiagnosticEngine &getDiags() const;\n\n \/\/ Make vanilla new\/delete illegal for Decls.\n void *operator new(size_t Bytes) = delete;\n void operator delete(void *Data) = delete;\n\n \/\/ Only allow allocation of Decls using the allocator in ASTContext\n \/\/ or by doing a placement new.\n void *operator new(size_t Bytes, const ASTContext &C,\n unsigned Alignment = alignof(Decl));\n void *operator new(size_t Bytes, void *Mem) { \n assert(Mem); \n return Mem; \n }\n};\n\n\/\/\/ Allocates memory for a Decl with the given \\p baseSize. If necessary,\n\/\/\/ it includes additional space immediately preceding the Decl for a ClangNode.\n\/\/\/ \\note \\p baseSize does not need to include space for a ClangNode if\n\/\/\/ requested -- the necessary space will be added automatically.\ntemplate \nvoid *allocateMemoryForDecl(AllocatorTy &allocator, size_t baseSize,\n bool includeSpaceForClangNode) {\n static_assert(alignof(DeclTy) >= sizeof(void *),\n \"A pointer must fit in the alignment of the DeclTy!\");\n\n size_t size = baseSize;\n if (includeSpaceForClangNode)\n size += alignof(DeclTy);\n\n void *mem = allocator.Allocate(size, alignof(DeclTy));\n if (includeSpaceForClangNode)\n mem = reinterpret_cast(mem) + alignof(DeclTy);\n return mem;\n}\n\nenum class RequirementReprKind : unsigned {\n \/\/\/ A type bound T : P, where T is a type that depends on a generic\n \/\/\/ parameter and P is some type that should bound T, either as a concrete\n \/\/\/ supertype or a protocol to which T must conform.\n TypeConstraint,\n\n \/\/\/ A same-type requirement T == U, where T and U are types that shall be\n \/\/\/ equivalent.\n SameType,\n\n \/\/\/ A layout bound T : L, where T is a type that depends on a generic\n \/\/\/ parameter and L is some layout specification that should bound T.\n LayoutConstraint,\n\n \/\/ Note: there is code that packs this enum in a 2-bit bitfield. Audit users\n \/\/ when adding enumerators.\n};\n\n\/\/\/ A single requirement in a 'where' clause, which places additional\n\/\/\/ restrictions on the generic parameters or associated types of a generic\n\/\/\/ function, type, or protocol.\n\/\/\/\n\/\/\/ This always represents a requirement spelled in the source code. It is\n\/\/\/ never generated implicitly.\n\/\/\/\n\/\/\/ \\c GenericParamList assumes these are POD-like.\nclass RequirementRepr {\n SourceLoc SeparatorLoc;\n RequirementReprKind Kind : 2;\n bool Invalid : 1;\n TypeLoc FirstType;\n\n \/\/\/ The second element represents the right-hand side of the constraint.\n \/\/\/ It can be e.g. a type or a layout constraint.\n union {\n TypeLoc SecondType;\n LayoutConstraintLoc SecondLayout;\n };\n\n \/\/\/ Set during deserialization; used to print out the requirements accurately\n \/\/\/ for the generated interface.\n StringRef AsWrittenString;\n\n RequirementRepr(SourceLoc SeparatorLoc, RequirementReprKind Kind,\n TypeLoc FirstType, TypeLoc SecondType)\n : SeparatorLoc(SeparatorLoc), Kind(Kind), Invalid(false),\n FirstType(FirstType), SecondType(SecondType) { }\n\n RequirementRepr(SourceLoc SeparatorLoc, RequirementReprKind Kind,\n TypeLoc FirstType, LayoutConstraintLoc SecondLayout)\n : SeparatorLoc(SeparatorLoc), Kind(Kind), Invalid(false),\n FirstType(FirstType), SecondLayout(SecondLayout) { }\n\n void printImpl(ASTPrinter &OS, bool AsWritten) const;\n\npublic:\n \/\/\/ Construct a new type-constraint requirement.\n \/\/\/\n \/\/\/ \\param Subject The type that must conform to the given protocol or\n \/\/\/ composition, or be a subclass of the given class type.\n \/\/\/ \\param ColonLoc The location of the ':', or an invalid location if\n \/\/\/ this requirement was implied.\n \/\/\/ \\param Constraint The protocol or protocol composition to which the\n \/\/\/ subject must conform, or superclass from which the subject must inherit.\n static RequirementRepr getTypeConstraint(TypeLoc Subject,\n SourceLoc ColonLoc,\n TypeLoc Constraint) {\n return { ColonLoc, RequirementReprKind::TypeConstraint, Subject, Constraint };\n }\n\n \/\/\/ Construct a new same-type requirement.\n \/\/\/\n \/\/\/ \\param FirstType The first type.\n \/\/\/ \\param EqualLoc The location of the '==' in the same-type constraint, or\n \/\/\/ an invalid location if this requirement was implied.\n \/\/\/ \\param SecondType The second type.\n static RequirementRepr getSameType(TypeLoc FirstType,\n SourceLoc EqualLoc,\n TypeLoc SecondType) {\n return { EqualLoc, RequirementReprKind::SameType, FirstType, SecondType };\n }\n\n \/\/\/ Construct a new layout-constraint requirement.\n \/\/\/\n \/\/\/ \\param Subject The type that must conform to the given layout \n \/\/\/ requirement.\n \/\/\/ \\param ColonLoc The location of the ':', or an invalid location if\n \/\/\/ this requirement was implied.\n \/\/\/ \\param Layout The layout requirement to which the\n \/\/\/ subject must conform.\n static RequirementRepr getLayoutConstraint(TypeLoc Subject,\n SourceLoc ColonLoc,\n LayoutConstraintLoc Layout) {\n return {ColonLoc, RequirementReprKind::LayoutConstraint, Subject,\n Layout};\n }\n\n \/\/\/ Determine the kind of requirement\n RequirementReprKind getKind() const { return Kind; }\n\n \/\/\/ Determine whether this requirement is invalid.\n bool isInvalid() const { return Invalid; }\n\n \/\/\/ Mark this requirement invalid.\n void setInvalid() { Invalid = true; }\n\n \/\/\/ For a type-bound requirement, return the subject of the\n \/\/\/ conformance relationship.\n Type getSubject() const {\n assert(getKind() == RequirementReprKind::TypeConstraint ||\n getKind() == RequirementReprKind::LayoutConstraint);\n return FirstType.getType();\n }\n\n TypeRepr *getSubjectRepr() const {\n assert(getKind() == RequirementReprKind::TypeConstraint ||\n getKind() == RequirementReprKind::LayoutConstraint);\n return FirstType.getTypeRepr();\n }\n\n TypeLoc &getSubjectLoc() {\n assert(getKind() == RequirementReprKind::TypeConstraint ||\n getKind() == RequirementReprKind::LayoutConstraint);\n return FirstType;\n }\n\n const TypeLoc &getSubjectLoc() const {\n assert(getKind() == RequirementReprKind::TypeConstraint ||\n getKind() == RequirementReprKind::LayoutConstraint);\n return FirstType;\n }\n\n \/\/\/ For a type-bound requirement, return the protocol or to which\n \/\/\/ the subject conforms or superclass it inherits.\n Type getConstraint() const {\n assert(getKind() == RequirementReprKind::TypeConstraint);\n return SecondType.getType();\n }\n\n TypeRepr *getConstraintRepr() const {\n assert(getKind() == RequirementReprKind::TypeConstraint);\n return SecondType.getTypeRepr();\n }\n\n TypeLoc &getConstraintLoc() {\n assert(getKind() == RequirementReprKind::TypeConstraint);\n return SecondType;\n }\n\n const TypeLoc &getConstraintLoc() const {\n assert(getKind() == RequirementReprKind::TypeConstraint);\n return SecondType;\n }\n\n LayoutConstraint getLayoutConstraint() const {\n assert(getKind() == RequirementReprKind::LayoutConstraint);\n return SecondLayout.getLayoutConstraint();\n }\n\n LayoutConstraintLoc &getLayoutConstraintLoc() {\n assert(getKind() == RequirementReprKind::LayoutConstraint);\n return SecondLayout;\n }\n\n const LayoutConstraintLoc &getLayoutConstraintLoc() const {\n assert(getKind() == RequirementReprKind::LayoutConstraint);\n return SecondLayout;\n }\n\n \/\/\/ Retrieve the first type of a same-type requirement.\n Type getFirstType() const {\n assert(getKind() == RequirementReprKind::SameType);\n return FirstType.getType();\n }\n\n TypeRepr *getFirstTypeRepr() const {\n assert(getKind() == RequirementReprKind::SameType);\n return FirstType.getTypeRepr();\n }\n\n TypeLoc &getFirstTypeLoc() {\n assert(getKind() == RequirementReprKind::SameType);\n return FirstType;\n }\n\n const TypeLoc &getFirstTypeLoc() const {\n assert(getKind() == RequirementReprKind::SameType);\n return FirstType;\n }\n\n \/\/\/ Retrieve the second type of a same-type requirement.\n Type getSecondType() const {\n assert(getKind() == RequirementReprKind::SameType);\n return SecondType.getType();\n }\n\n TypeRepr *getSecondTypeRepr() const {\n assert(getKind() == RequirementReprKind::SameType);\n return SecondType.getTypeRepr();\n }\n\n TypeLoc &getSecondTypeLoc() {\n assert(getKind() == RequirementReprKind::SameType);\n return SecondType;\n }\n\n const TypeLoc &getSecondTypeLoc() const {\n assert(getKind() == RequirementReprKind::SameType);\n return SecondType;\n }\n\n \/\/\/ Retrieve the location of the ':' or '==' in an explicitly-written\n \/\/\/ conformance or same-type requirement respectively.\n SourceLoc getSeparatorLoc() const {\n return SeparatorLoc;\n }\n\n SourceRange getSourceRange() const {\n if (getKind() == RequirementReprKind::LayoutConstraint)\n return SourceRange(FirstType.getSourceRange().Start,\n SecondLayout.getSourceRange().End);\n return SourceRange(FirstType.getSourceRange().Start,\n SecondType.getSourceRange().End);\n }\n\n \/\/\/ Retrieve the first or subject type representation from the \\c repr,\n \/\/\/ or \\c nullptr if \\c repr is null.\n static TypeRepr *getFirstTypeRepr(const RequirementRepr *repr) {\n if (!repr) return nullptr;\n return repr->FirstType.getTypeRepr();\n }\n\n \/\/\/ Retrieve the second or constraint type representation from the \\c repr,\n \/\/\/ or \\c nullptr if \\c repr is null.\n static TypeRepr *getSecondTypeRepr(const RequirementRepr *repr) {\n if (!repr) return nullptr;\n assert(repr->getKind() == RequirementReprKind::TypeConstraint ||\n repr->getKind() == RequirementReprKind::SameType);\n return repr->SecondType.getTypeRepr();\n }\n\n SWIFT_DEBUG_DUMP;\n void print(raw_ostream &OS) const;\n void print(ASTPrinter &Printer) const;\n};\n\nusing GenericParamSource = PointerUnion;\n\n\/\/\/ GenericParamList - A list of generic parameters that is part of a generic\n\/\/\/ function or type, along with extra requirements placed on those generic\n\/\/\/ parameters and types derived from them.\nclass GenericParamList final :\n private llvm::TrailingObjects {\n friend TrailingObjects;\n\n SourceRange Brackets;\n unsigned NumParams;\n SourceLoc WhereLoc;\n MutableArrayRef Requirements;\n\n GenericParamList *OuterParameters;\n\n SourceLoc TrailingWhereLoc;\n unsigned FirstTrailingWhereArg;\n\n GenericParamList(SourceLoc LAngleLoc,\n ArrayRef Params,\n SourceLoc WhereLoc,\n MutableArrayRef Requirements,\n SourceLoc RAngleLoc);\n \n \/\/ Don't copy.\n GenericParamList(const GenericParamList &) = delete;\n GenericParamList &operator=(const GenericParamList &) = delete;\n \npublic:\n \/\/\/ create - Create a new generic parameter list within the given AST context.\n \/\/\/\n \/\/\/ \\param Context The ASTContext in which the generic parameter list will\n \/\/\/ be allocated.\n \/\/\/ \\param LAngleLoc The location of the opening angle bracket ('<')\n \/\/\/ \\param Params The list of generic parameters, which will be copied into\n \/\/\/ ASTContext-allocated memory.\n \/\/\/ \\param RAngleLoc The location of the closing angle bracket ('>')\n static GenericParamList *create(ASTContext &Context,\n SourceLoc LAngleLoc,\n ArrayRef Params,\n SourceLoc RAngleLoc);\n\n \/\/\/ create - Create a new generic parameter list and \"where\" clause within\n \/\/\/ the given AST context.\n \/\/\/\n \/\/\/ \\param Context The ASTContext in which the generic parameter list will\n \/\/\/ be allocated.\n \/\/\/ \\param LAngleLoc The location of the opening angle bracket ('<')\n \/\/\/ \\param Params The list of generic parameters, which will be copied into\n \/\/\/ ASTContext-allocated memory.\n \/\/\/ \\param WhereLoc The location of the 'where' keyword, if any.\n \/\/\/ \\param Requirements The list of requirements, which will be copied into\n \/\/\/ ASTContext-allocated memory.\n \/\/\/ \\param RAngleLoc The location of the closing angle bracket ('>')\n static GenericParamList *create(const ASTContext &Context,\n SourceLoc LAngleLoc,\n ArrayRef Params,\n SourceLoc WhereLoc,\n ArrayRef Requirements,\n SourceLoc RAngleLoc);\n\n MutableArrayRef getParams() {\n return {getTrailingObjects(), NumParams};\n }\n\n ArrayRef getParams() const {\n return {getTrailingObjects(), NumParams};\n }\n\n using iterator = GenericTypeParamDecl **;\n using const_iterator = const GenericTypeParamDecl * const *;\n\n unsigned size() const { return NumParams; }\n iterator begin() { return getParams().begin(); }\n iterator end() { return getParams().end(); }\n const_iterator begin() const { return getParams().begin(); }\n const_iterator end() const { return getParams().end(); }\n\n \/\/\/ Retrieve the location of the 'where' keyword, or an invalid\n \/\/\/ location if 'where' was not present.\n SourceLoc getWhereLoc() const { return WhereLoc; }\n\n \/\/\/ Retrieve the set of additional requirements placed on these\n \/\/\/ generic parameters and types derived from them.\n \/\/\/\n \/\/\/ This list may contain both explicitly-written requirements as well as\n \/\/\/ implicitly-generated requirements, and may be non-empty even if no\n \/\/\/ 'where' keyword is present.\n MutableArrayRef getRequirements() { return Requirements; }\n\n \/\/\/ Retrieve the set of additional requirements placed on these\n \/\/\/ generic parameters and types derived from them.\n \/\/\/\n \/\/\/ This list may contain both explicitly-written requirements as well as\n \/\/\/ implicitly-generated requirements, and may be non-empty even if no\n \/\/\/ 'where' keyword is present.\n ArrayRef getRequirements() const { return Requirements; }\n\n \/\/\/ Retrieve only those requirements that are written within the brackets,\n \/\/\/ which does not include any requirements written in a trailing where\n \/\/\/ clause.\n ArrayRef getNonTrailingRequirements() const {\n return Requirements.slice(0, FirstTrailingWhereArg);\n }\n\n \/\/\/ Retrieve only those requirements written in a trailing where\n \/\/\/ clause.\n ArrayRef getTrailingRequirements() const {\n return Requirements.slice(FirstTrailingWhereArg);\n }\n\n \/\/\/ Determine whether the generic parameters have a trailing where clause.\n bool hasTrailingWhereClause() const {\n return FirstTrailingWhereArg < Requirements.size();\n }\n\n \/\/\/ Add a trailing 'where' clause to the list of requirements.\n \/\/\/\n \/\/\/ Trailing where clauses are written outside the angle brackets, after the\n \/\/\/ main part of a declaration's signature.\n void addTrailingWhereClause(ASTContext &ctx, SourceLoc trailingWhereLoc,\n ArrayRef trailingRequirements);\n \n \/\/\/ Retrieve the outer generic parameter list.\n \/\/\/\n \/\/\/ This is used for extensions of nested types, and in SIL mode, where a\n \/\/\/ single lexical context can have multiple logical generic parameter\n \/\/\/ lists.\n GenericParamList *getOuterParameters() const { return OuterParameters; }\n\n \/\/\/ Set the outer generic parameter list. See \\c getOuterParameters\n \/\/\/ for more information.\n void setOuterParameters(GenericParamList *Outer) { OuterParameters = Outer; }\n\n SourceLoc getLAngleLoc() const { return Brackets.Start; }\n SourceLoc getRAngleLoc() const { return Brackets.End; }\n\n SourceRange getSourceRange() const { return Brackets; }\n\n \/\/\/ Retrieve the source range covering the where clause.\n SourceRange getWhereClauseSourceRange() const {\n if (WhereLoc.isInvalid())\n return SourceRange();\n\n auto endLoc = Requirements[FirstTrailingWhereArg-1].getSourceRange().End;\n return SourceRange(WhereLoc, endLoc);\n }\n\n \/\/\/ Retrieve the source range covering the trailing where clause.\n SourceRange getTrailingWhereClauseSourceRange() const {\n if (!hasTrailingWhereClause())\n return SourceRange();\n\n return SourceRange(TrailingWhereLoc,\n Requirements.back().getSourceRange().End);\n }\n\n \/\/\/ Configure the depth of the generic parameters in this list.\n void setDepth(unsigned depth);\n\n \/\/\/ Create a copy of the generic parameter list and all of its generic\n \/\/\/ parameter declarations. The copied generic parameters are re-parented\n \/\/\/ to the given DeclContext.\n GenericParamList *clone(DeclContext *dc) const;\n\n void print(raw_ostream &OS) const;\n SWIFT_DEBUG_DUMP;\n};\n \n\/\/\/ A trailing where clause.\nclass alignas(RequirementRepr) TrailingWhereClause final :\n private llvm::TrailingObjects {\n friend TrailingObjects;\n\n SourceLoc WhereLoc;\n\n \/\/\/ The number of requirements. The actual requirements are tail-allocated.\n unsigned NumRequirements;\n\n TrailingWhereClause(SourceLoc whereLoc,\n ArrayRef requirements);\n\npublic:\n \/\/\/ Create a new trailing where clause with the given set of requirements.\n static TrailingWhereClause *create(ASTContext &ctx, SourceLoc whereLoc,\n ArrayRef requirements);\n\n \/\/\/ Retrieve the location of the 'where' keyword.\n SourceLoc getWhereLoc() const { return WhereLoc; }\n\n \/\/\/ Retrieve the set of requirements.\n MutableArrayRef getRequirements() {\n return {getTrailingObjects(), NumRequirements};\n }\n\n \/\/\/ Retrieve the set of requirements.\n ArrayRef getRequirements() const {\n return {getTrailingObjects(), NumRequirements};\n }\n\n \/\/\/ Compute the source range containing this trailing where clause.\n SourceRange getSourceRange() const {\n return SourceRange(WhereLoc,\n getRequirements().back().getSourceRange().End);\n }\n\n void print(llvm::raw_ostream &OS, bool printWhereKeyword) const;\n};\n\n\/\/ A private class for forcing exact field layout.\nclass alignas(8) _GenericContext {\n\/\/ Not really public. See GenericContext.\npublic:\n llvm::PointerIntPair GenericParamsAndBit;\n\n \/\/\/ The trailing where clause.\n \/\/\/\n \/\/\/ Note that this is not currently serialized, because semantic analysis\n \/\/\/ moves the trailing where clause into the generic parameter list.\n TrailingWhereClause *TrailingWhere = nullptr;\n\n \/\/\/ The generic signature of this declaration.\n llvm::PointerIntPair GenericSigAndBit;\n};\n\nclass GenericContext : private _GenericContext, public DeclContext {\n friend class GenericParamListRequest;\n friend class GenericSignatureRequest;\n \nprotected:\n GenericContext(DeclContextKind Kind, DeclContext *Parent,\n GenericParamList *Params);\n\npublic:\n \/\/\/ Retrieve the set of parameters to a generic context, or null if\n \/\/\/ this context is not generic.\n GenericParamList *getGenericParams() const;\n\n \/\/\/ Determine whether this context has generic parameters\n \/\/\/ of its own.\n \/\/\/\n \/\/\/ \\code\n \/\/\/ class C {\n \/\/\/ func f1() {} \/\/ isGeneric == false\n \/\/\/ func f2() {} \/\/ isGeneric == true\n \/\/\/ }\n \/\/\/\n \/\/\/ protocol P { \/\/ isGeneric == true due to implicit Self param\n \/\/\/ func p() \/\/ isGeneric == false\n \/\/\/ }\n \/\/\/ \\endcode\n bool isGeneric() const { return getGenericParams() != nullptr; }\n bool hasComputedGenericSignature() const;\n bool isComputingGenericSignature() const;\n \n \/\/\/ Retrieve the trailing where clause for this extension, if any.\n TrailingWhereClause *getTrailingWhereClause() const {\n return TrailingWhere;\n }\n\n \/\/\/ Set the trailing where clause for this extension.\n void setTrailingWhereClause(TrailingWhereClause *trailingWhereClause) {\n TrailingWhere = trailingWhereClause;\n }\n\n \/\/\/ Retrieve the generic signature for this context.\n GenericSignature getGenericSignature() const;\n\n \/\/\/ Retrieve the generic context for this context.\n GenericEnvironment *getGenericEnvironment() const;\n\n \/\/\/ Retrieve the innermost generic parameter types.\n TypeArrayView getInnermostGenericParamTypes() const;\n\n \/\/\/ Retrieve the generic requirements.\n ArrayRef getGenericRequirements() const;\n\n \/\/\/ Set the generic signature of this context.\n void setGenericSignature(GenericSignature genericSig);\n\n \/\/\/ Retrieve the position of any where clause for this context's\n \/\/\/ generic parameters.\n SourceRange getGenericTrailingWhereClauseSourceRange() const;\n};\nstatic_assert(sizeof(_GenericContext) + sizeof(DeclContext) ==\n sizeof(GenericContext), \"Please add fields to _GenericContext\");\n\n\/\/\/ Describes what kind of name is being imported.\n\/\/\/\n\/\/\/ If the enumerators here are changed, make sure to update all diagnostics\n\/\/\/ using ImportKind as a select index.\nenum class ImportKind : uint8_t {\n Module = 0,\n Type,\n Struct,\n Class,\n Enum,\n Protocol,\n Var,\n Func\n};\n\n\/\/\/ ImportDecl - This represents a single import declaration, e.g.:\n\/\/\/ import Swift\n\/\/\/ import typealias Swift.Int\nclass ImportDecl final : public Decl,\n private llvm::TrailingObjects> {\n friend TrailingObjects;\n friend class Decl;\npublic:\n typedef Located AccessPathElement;\n\nprivate:\n SourceLoc ImportLoc;\n SourceLoc KindLoc;\n\n \/\/\/ The resolved module.\n ModuleDecl *Mod = nullptr;\n\n ImportDecl(DeclContext *DC, SourceLoc ImportLoc, ImportKind K,\n SourceLoc KindLoc, ArrayRef Path);\n\npublic:\n static ImportDecl *create(ASTContext &C, DeclContext *DC,\n SourceLoc ImportLoc, ImportKind Kind,\n SourceLoc KindLoc,\n ArrayRef Path,\n ClangNode ClangN = ClangNode());\n\n \/\/\/ Returns the import kind that is most appropriate for \\p VD.\n \/\/\/\n \/\/\/ Note that this will never return \\c Type; an imported typealias will use\n \/\/\/ the more specific kind from its underlying type.\n static ImportKind getBestImportKind(const ValueDecl *VD);\n\n \/\/\/ Returns the most appropriate import kind for the given list of decls.\n \/\/\/\n \/\/\/ If the list is non-homogeneous, or if there is more than one decl that\n \/\/\/ cannot be overloaded, returns None.\n static Optional findBestImportKind(ArrayRef Decls);\n\n ArrayRef getFullAccessPath() const {\n return {getTrailingObjects(),\n static_cast(Bits.ImportDecl.NumPathElements)};\n }\n\n ArrayRef getModulePath() const {\n auto result = getFullAccessPath();\n if (getImportKind() != ImportKind::Module)\n result = result.slice(0, result.size()-1);\n return result;\n }\n\n ArrayRef getDeclPath() const {\n if (getImportKind() == ImportKind::Module)\n return {};\n return getFullAccessPath().back();\n }\n\n ImportKind getImportKind() const {\n return static_cast(Bits.ImportDecl.ImportKind);\n }\n\n bool isExported() const {\n return getAttrs().hasAttribute();\n }\n\n ModuleDecl *getModule() const { return Mod; }\n void setModule(ModuleDecl *M) { Mod = M; }\n\n \/\/\/ For a scoped import such as 'import class Foundation.NSString', retrieve\n \/\/\/ the decls it references. Otherwise, returns an empty array.\n ArrayRef getDecls() const;\n\n const clang::Module *getClangModule() const {\n return getClangNode().getClangModule();\n }\n\n SourceLoc getStartLoc() const { return ImportLoc; }\n SourceLoc getLocFromSource() const { return getFullAccessPath().front().Loc; }\n SourceRange getSourceRange() const {\n return SourceRange(ImportLoc, getFullAccessPath().back().Loc);\n }\n SourceLoc getKindLoc() const { return KindLoc; }\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::Import;\n }\n};\n\n\/\/\/ ExtensionDecl - This represents a type extension containing methods\n\/\/\/ associated with the type. This is not a ValueDecl and has no Type because\n\/\/\/ there are no runtime values of the Extension's type. \nclass ExtensionDecl final : public GenericContext, public Decl,\n public IterableDeclContext {\n SourceLoc ExtensionLoc; \/\/ Location of 'extension' keyword.\n SourceRange Braces;\n\n \/\/\/ The type being extended.\n TypeRepr *ExtendedTypeRepr;\n\n \/\/\/ The nominal type being extended.\n \/\/\/\n \/\/\/ The bit indicates whether binding has been attempted. The pointer can be\n \/\/\/ null if either no binding was attempted or if binding could not find the\n \/\/\/ extended nominal.\n llvm::PointerIntPair ExtendedNominal;\n\n MutableArrayRef Inherited;\n\n \/\/\/ The next extension in the linked list of extensions.\n \/\/\/\n \/\/\/ The bit indicates whether this extension has been resolved to refer to\n \/\/\/ a known nominal type.\n llvm::PointerIntPair NextExtension\n = {nullptr, false};\n\n \/\/\/ Note that we have added a member into the iterable declaration context.\n void addedMember(Decl *member);\n\n friend class ExtensionIterator;\n friend class NominalTypeDecl;\n friend class MemberLookupTable;\n friend class ConformanceLookupTable;\n friend class IterableDeclContext;\n\n ExtensionDecl(SourceLoc extensionLoc, TypeRepr *extendedType,\n MutableArrayRef inherited,\n DeclContext *parent,\n TrailingWhereClause *trailingWhereClause);\n\n \/\/\/ Retrieve the conformance loader (if any), and removing it in the\n \/\/\/ same operation. The caller is responsible for loading the\n \/\/\/ conformances.\n std::pair takeConformanceLoader() {\n if (!Bits.ExtensionDecl.HasLazyConformances)\n return { nullptr, 0 };\n\n return takeConformanceLoaderSlow();\n }\n\n \/\/\/ Slow path for \\c takeConformanceLoader().\n std::pair takeConformanceLoaderSlow();\n\n friend class ExtendedNominalRequest;\n friend class Decl;\npublic:\n using Decl::getASTContext;\n\n \/\/\/ Create a new extension declaration.\n static ExtensionDecl *create(ASTContext &ctx, SourceLoc extensionLoc,\n TypeRepr *extendedType,\n MutableArrayRef inherited,\n DeclContext *parent,\n TrailingWhereClause *trailingWhereClause,\n ClangNode clangNode = ClangNode());\n\n SourceLoc getStartLoc() const { return ExtensionLoc; }\n SourceLoc getLocFromSource() const { return ExtensionLoc; }\n SourceRange getSourceRange() const {\n return { ExtensionLoc, Braces.End };\n }\n\n SourceRange getBraces() const { return Braces; }\n void setBraces(SourceRange braces) { Braces = braces; }\n\n bool hasBeenBound() const { return ExtendedNominal.getInt(); }\n\n void setExtendedNominal(NominalTypeDecl *n) {\n ExtendedNominal.setPointerAndInt(n, true);\n }\n\n \/\/\/ Retrieve the type being extended.\n \/\/\/\n \/\/\/ Only use this entry point when the complete type, as spelled in the source,\n \/\/\/ is required. For most clients, \\c getExtendedNominal(), which provides\n \/\/\/ only the \\c NominalTypeDecl, will suffice.\n Type getExtendedType() const;\n\n \/\/\/ Retrieve the nominal type declaration that is being extended.\n \/\/\/ Will trip an assertion if the declaration has not already been computed.\n \/\/\/ In order to fail fast when type checking work is attempted\n \/\/\/ before extension binding has taken place.\n\n NominalTypeDecl *getExtendedNominal() const;\n\n \/\/\/ Compute the nominal type declaration that is being extended.\n NominalTypeDecl *computeExtendedNominal() const;\n\n \/\/\/ \\c hasBeenBound means nothing if this extension can never been bound\n \/\/\/ because it is not at the top level.\n bool canNeverBeBound() const;\n\n bool hasValidParent() const;\n\n \/\/\/ Determine whether this extension has already been bound to a nominal\n \/\/\/ type declaration.\n bool alreadyBoundToNominal() const { return NextExtension.getInt(); }\n\n \/\/\/ Retrieve the extended type definition as written in the source, if it exists.\n TypeRepr *getExtendedTypeRepr() const { return ExtendedTypeRepr; }\n \n \/\/\/ Retrieve the set of protocols that this type inherits (i.e,\n \/\/\/ explicitly conforms to).\n MutableArrayRef getInherited() { return Inherited; }\n ArrayRef getInherited() const { return Inherited; }\n\n void setInherited(MutableArrayRef i) { Inherited = i; }\n\n bool hasDefaultAccessLevel() const {\n return Bits.ExtensionDecl.DefaultAndMaxAccessLevel != 0;\n }\n\n uint8_t getDefaultAndMaxAccessLevelBits() const {\n return Bits.ExtensionDecl.DefaultAndMaxAccessLevel;\n }\n void setDefaultAndMaxAccessLevelBits(AccessLevel defaultAccess,\n AccessLevel maxAccess) {\n Bits.ExtensionDecl.DefaultAndMaxAccessLevel =\n (1 << (static_cast(defaultAccess) - 1)) |\n (1 << (static_cast(maxAccess) - 1));\n }\n\n AccessLevel getDefaultAccessLevel() const;\n AccessLevel getMaxAccessLevel() const;\n\n void setDefaultAndMaxAccess(AccessLevel defaultAccess,\n AccessLevel maxAccess) {\n assert(!hasDefaultAccessLevel() && \"default access level already set\");\n assert(maxAccess >= defaultAccess);\n assert(maxAccess != AccessLevel::Private && \"private not valid\");\n assert(defaultAccess != AccessLevel::Private && \"private not valid\");\n setDefaultAndMaxAccessLevelBits(defaultAccess, maxAccess);\n assert(getDefaultAccessLevel() == defaultAccess && \"not enough bits\");\n assert(getMaxAccessLevel() == maxAccess && \"not enough bits\");\n }\n\n void setConformanceLoader(LazyMemberLoader *resolver, uint64_t contextData);\n\n \/\/\/ Determine whether this is a constrained extension, which adds additional\n \/\/\/ requirements beyond those of the nominal type.\n bool isConstrainedExtension() const;\n \n \/\/\/ Determine whether this extension context is interchangeable with the\n \/\/\/ original nominal type context.\n \/\/\/\n \/\/\/ False if any of the following properties hold:\n \/\/\/ - the extension is defined in a different module from the original\n \/\/\/ nominal type decl,\n \/\/\/ - the extension is constrained, or\n \/\/\/ - the extension is to a protocol.\n \/\/\/ FIXME: In a world where protocol extensions are dynamically dispatched,\n \/\/\/ \"extension is to a protocol\" would no longer be a reason to use the\n \/\/\/ extension mangling, because an extension method implementation could be\n \/\/\/ resiliently moved into the original protocol itself.\n bool isEquivalentToExtendedContext() const;\n\n \/\/ Implement isa\/cast\/dyncast\/etc.\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::Extension;\n }\n static bool classof(const DeclContext *C) {\n if (auto D = C->getAsDecl())\n return classof(D);\n return false;\n }\n static bool classof(const IterableDeclContext *C) {\n return C->getIterableContextKind() \n == IterableDeclContextKind::ExtensionDecl;\n }\n\n using DeclContext::operator new;\n};\n\n\/\/\/ Iterator that walks the extensions of a particular type.\nclass ExtensionIterator {\n ExtensionDecl *current;\n\npublic:\n ExtensionIterator() : current() { }\n explicit ExtensionIterator(ExtensionDecl *current) : current(current) { }\n\n ExtensionDecl *operator*() const { return current; }\n ExtensionDecl *operator->() const { return current; }\n\n ExtensionIterator &operator++() {\n current = current->NextExtension.getPointer();\n return *this;\n }\n\n ExtensionIterator operator++(int) {\n ExtensionIterator tmp = *this;\n ++(*this);\n return tmp;\n }\n\n friend bool operator==(ExtensionIterator x, ExtensionIterator y) {\n return x.current == y.current;\n }\n\n friend bool operator!=(ExtensionIterator x, ExtensionIterator y) {\n return x.current != y.current;\n }\n};\n\n\/\/\/ Range that covers a set of extensions.\nclass ExtensionRange {\n ExtensionIterator first;\n ExtensionIterator last;\n\npublic:\n\n ExtensionRange(ExtensionIterator first, ExtensionIterator last)\n : first(first), last(last) { }\n\n typedef ExtensionIterator iterator;\n iterator begin() const { return first; }\n iterator end() const { return last; }\n};\n \n \n\/\/\/ This represents one entry in a PatternBindingDecl, which are pairs of\n\/\/\/ Pattern and Initialization expression. The pattern is always present, but\n\/\/\/ the initializer can be null if there is none.\nclass PatternBindingEntry {\n enum class Flags {\n Checked = 1 << 0,\n Removed = 1 << 1,\n \/\/\/ Whether the contents of this initializer were subsumed by\n \/\/\/ some other initialization, e.g., a lazy property's initializer\n \/\/\/ gets subsumed by the getter body.\n Subsumed = 1 << 2,\n };\n llvm::PointerIntPair> PatternAndFlags;\n\n struct InitializerAndEqualLoc {\n \/\/ When the initializer is removed we don't actually clear the pointers\n \/\/ because we might need to get initializer's source range. Since the\n \/\/ initializer is ASTContext-allocated it is safe.\n \n \/\/\/ Exactly the expr the programmer wrote\n Expr *originalInit;\n \/\/\/ Might be transformed, e.g. for a property wrapper. In the absence of\n \/\/\/ transformation or synthesis, holds the expr as parsed.\n Expr *initAfterSynthesis;\n \/\/\/ The location of the equal '=' token.\n SourceLoc EqualLoc;\n };\n\n union {\n \/\/\/ The initializer expression and its '=' token loc.\n InitializerAndEqualLoc InitExpr;\n\n \/\/\/ The text of the initializer expression if deserialized from a module.\n StringRef InitStringRepresentation;\n };\n\n enum class PatternFlags {\n IsText = 1 << 0,\n IsFullyValidated = 1 << 1,\n };\n \/\/\/ The initializer context used for this pattern binding entry.\n llvm::PointerIntPair>\n InitContextAndFlags;\n\n \/\/\/ Values captured by this initializer.\n CaptureInfo Captures;\n\n friend class Parser;\n friend class PatternBindingInitializer;\n friend class PatternBindingDecl;\n friend class ast_scope::AbstractPatternEntryScope;\n friend class ast_scope::PatternEntryDeclScope;\n friend class ast_scope::PatternEntryInitializerScope;\n\nprivate:\n \/\/ FIXME: This API is transitional. Once the callers of\n \/\/ typeCheckPatternBinding are requestified, merge this bit with\n \/\/ Flags::Checked.\n friend class PatternBindingEntryRequest;\n\n bool isFullyValidated() const {\n return InitContextAndFlags.getInt().contains(\n PatternFlags::IsFullyValidated);\n }\n void setFullyValidated() {\n InitContextAndFlags.setInt(InitContextAndFlags.getInt() |\n PatternFlags::IsFullyValidated);\n }\n\npublic:\n \/\/\/ \\p E is the initializer as parsed.\n PatternBindingEntry(Pattern *P, SourceLoc EqualLoc, Expr *E,\n DeclContext *InitContext)\n : PatternAndFlags(P, {}), InitExpr({E, E, EqualLoc}),\n InitContextAndFlags({InitContext, None}) {}\n\nprivate:\n Pattern *getPattern() const { return PatternAndFlags.getPointer(); }\n void setPattern(Pattern *P) { PatternAndFlags.setPointer(P); }\n\n \/\/\/ Whether the given pattern binding entry is initialized.\n \/\/\/\n \/\/\/ \\param onlyExplicit Only consider explicit initializations (rather\n \/\/\/ than implicitly-generated ones).\n bool isInitialized(bool onlyExplicit = false) const;\n\n Expr *getInit() const {\n if (PatternAndFlags.getInt().contains(Flags::Removed) ||\n InitContextAndFlags.getInt().contains(PatternFlags::IsText))\n return nullptr;\n return InitExpr.initAfterSynthesis;\n }\n \/\/\/ Retrieve the initializer if it should be executed to initialize this\n \/\/\/ particular pattern binding.\n Expr *getExecutableInit() const {\n return isInitializerSubsumed() ? nullptr : getInit();\n }\n SourceRange getOriginalInitRange() const;\n void setInit(Expr *E);\n\n \/\/\/ Gets the text of the initializer expression, stripping out inactive\n \/\/\/ branches of any #ifs inside the expression.\n StringRef getInitStringRepresentation(SmallVectorImpl &scratch) const;\n\n \/\/\/ Sets the initializer string representation to the string that was\n \/\/\/ deserialized from a partial module.\n void setInitStringRepresentation(StringRef str) {\n InitStringRepresentation = str;\n InitContextAndFlags.setInt(InitContextAndFlags.getInt() |\n PatternFlags::IsText);\n }\n\n \/\/\/ Whether this pattern entry can generate a string representation of its\n \/\/\/ initializer expression.\n bool hasInitStringRepresentation() const;\n\n \/\/\/ Retrieve the location of the equal '=' token.\n SourceLoc getEqualLoc() const {\n return InitContextAndFlags.getInt().contains(PatternFlags::IsText)\n ? SourceLoc()\n : InitExpr.EqualLoc;\n }\n\n \/\/\/ Set the location of the equal '=' token.\n void setEqualLoc(SourceLoc equalLoc) {\n assert(!InitContextAndFlags.getInt().contains(PatternFlags::IsText) &&\n \"cannot set equal loc for textual initializer\");\n InitExpr.EqualLoc = equalLoc;\n }\n\n \/\/\/ Retrieve the initializer after the =, if any, as it was written in the\n \/\/\/ source.\n Expr *getOriginalInit() const;\n\n \/\/\/ Set the initializer after the = as it was written in the source.\n void setOriginalInit(Expr *);\n\n bool isInitializerChecked() const {\n return PatternAndFlags.getInt().contains(Flags::Checked);\n }\n void setInitializerChecked() {\n PatternAndFlags.setInt(PatternAndFlags.getInt() | Flags::Checked);\n }\n\n bool isInitializerSubsumed() const {\n return PatternAndFlags.getInt().contains(Flags::Subsumed);\n }\n void setInitializerSubsumed() {\n PatternAndFlags.setInt(PatternAndFlags.getInt() | Flags::Subsumed);\n }\n\n \/\/ Return the first variable initialized by this pattern.\n VarDecl *getAnchoringVarDecl() const;\n\n \/\/ Retrieve the declaration context for the initializer.\n DeclContext *getInitContext() const {\n return InitContextAndFlags.getPointer();\n }\n\n \/\/\/ Override the initializer context.\n void setInitContext(DeclContext *dc) { InitContextAndFlags.setPointer(dc); }\n\n SourceLoc getStartLoc() const;\n\n \/\/\/ Retrieve the end location covered by this pattern binding entry.\n \/\/\/\n \/\/\/ \\param omitAccessors Whether the computation should omit the accessors\n \/\/\/ from the source range.\n SourceLoc getEndLoc(bool omitAccessors = false) const;\n\n \/\/\/ Retrieve the source range covered by this pattern binding entry.\n \/\/\/\n \/\/\/ \\param omitAccessors Whether the computation should omit the accessors\n \/\/\/ from the source range.\n SourceRange getSourceRange(bool omitAccessors = false) const;\n\n CaptureInfo getCaptureInfo() const { return Captures; }\n void setCaptureInfo(CaptureInfo captures) { Captures = captures; }\n\n unsigned getNumBoundVariables() const;\n\nprivate:\n SourceLoc getLastAccessorEndLoc() const;\n};\n\n\/\/\/ This decl contains a pattern and optional initializer for a set\n\/\/\/ of one or more VarDecls declared together.\n\/\/\/\n\/\/\/ For example, in\n\/\/\/ \\code\n\/\/\/ var (a, b) = foo(), (c,d) = bar()\n\/\/\/ \\endcode\n\/\/\/\n\/\/\/ this includes two entries in the pattern list. The first contains the\n\/\/\/ pattern \"(a, b)\" and the initializer \"foo()\". The second contains the\n\/\/\/ pattern \"(c, d)\" and the initializer \"bar()\".\n\/\/\/\nclass PatternBindingDecl final : public Decl,\n private llvm::TrailingObjects {\n friend TrailingObjects;\n friend class Decl;\n friend class PatternBindingEntryRequest;\n\n SourceLoc StaticLoc; \/\/\/< Location of the 'static\/class' keyword, if present.\n SourceLoc VarLoc; \/\/\/< Location of the 'var' keyword.\n\n friend class Decl;\n \n PatternBindingDecl(SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,\n SourceLoc VarLoc, unsigned NumPatternEntries,\n DeclContext *Parent);\n SourceLoc getLocFromSource() const { return VarLoc; }\npublic:\n static PatternBindingDecl *create(ASTContext &Ctx, SourceLoc StaticLoc,\n StaticSpellingKind StaticSpelling,\n SourceLoc VarLoc,\n ArrayRef PatternList,\n DeclContext *Parent);\n\n static PatternBindingDecl *create(ASTContext &Ctx, SourceLoc StaticLoc,\n StaticSpellingKind StaticSpelling,\n SourceLoc VarLoc, Pattern *Pat,\n SourceLoc EqualLoc, Expr *E,\n DeclContext *Parent);\n\n static PatternBindingDecl *createImplicit(ASTContext &Ctx,\n StaticSpellingKind StaticSpelling,\n Pattern *Pat, Expr *E,\n DeclContext *Parent,\n SourceLoc VarLoc = SourceLoc());\n\n static PatternBindingDecl *createDeserialized(\n ASTContext &Ctx, SourceLoc StaticLoc,\n StaticSpellingKind StaticSpelling,\n SourceLoc VarLoc,\n unsigned NumPatternEntries,\n DeclContext *Parent);\n\n SourceLoc getStartLoc() const {\n return StaticLoc.isValid() ? StaticLoc : VarLoc;\n }\n SourceRange getSourceRange() const;\n\n unsigned getNumPatternEntries() const {\n return Bits.PatternBindingDecl.NumPatternEntries;\n }\n \n ArrayRef getPatternList() const {\n return const_cast(this)->getMutablePatternList();\n }\n\n void setInitStringRepresentation(unsigned i, StringRef str) {\n getMutablePatternList()[i].setInitStringRepresentation(str);\n }\n\n \/\/\/ Whether the given pattern entry is initialized.\n bool isInitialized(unsigned i) const {\n return getPatternList()[i].isInitialized();\n }\n\n Expr *getInit(unsigned i) const {\n return getPatternList()[i].getInit();\n }\n Expr *getExecutableInit(unsigned i) const {\n return getPatternList()[i].getExecutableInit();\n }\n Expr *getOriginalInit(unsigned i) const {\n return getPatternList()[i].getOriginalInit();\n }\n\n SourceRange getOriginalInitRange(unsigned i) const {\n return getPatternList()[i].getOriginalInitRange();\n }\n\n void setInit(unsigned i, Expr *E) {\n getMutablePatternList()[i].setInit(E);\n }\n\n Pattern *getPattern(unsigned i) const {\n return getPatternList()[i].getPattern();\n }\n \n void setPattern(unsigned i, Pattern *Pat, DeclContext *InitContext);\n\n DeclContext *getInitContext(unsigned i) const {\n return getPatternList()[i].getInitContext();\n }\n\n CaptureInfo getCaptureInfo(unsigned i) const {\n return getPatternList()[i].getCaptureInfo();\n }\n\n void setCaptureInfo(unsigned i, CaptureInfo captures) {\n getMutablePatternList()[i].setCaptureInfo(captures);\n }\n\n \/\/\/ Given that this PBD is the parent pattern for the specified VarDecl,\n \/\/\/ return the entry of the VarDecl in our PatternList. For example, in:\n \/\/\/\n \/\/\/ let (a,b) = foo(), (c,d) = bar()\n \/\/\/\n \/\/\/ \"a\" and \"b\" will have index 0, since they correspond to the first pattern,\n \/\/\/ and \"c\" and \"d\" will have index 1 since they correspond to the second one.\n unsigned getPatternEntryIndexForVarDecl(const VarDecl *VD) const;\n \n bool isInitializerChecked(unsigned i) const {\n return getPatternList()[i].isInitializerChecked();\n }\n\n void setInitializerChecked(unsigned i) {\n getMutablePatternList()[i].setInitializerChecked();\n }\n\n bool isInitializerSubsumed(unsigned i) const {\n return getPatternList()[i].isInitializerSubsumed();\n }\n\n void setInitializerSubsumed(unsigned i) {\n getMutablePatternList()[i].setInitializerSubsumed();\n }\n \n \/\/\/ Does this binding declare something that requires storage?\n bool hasStorage() const;\n\n \/\/\/ Determines whether this binding either has an initializer expression, or is\n \/\/\/ default initialized, without performing any type checking on it.\n bool isDefaultInitializable() const {\n for (unsigned i : range(getNumPatternEntries()))\n if (!isDefaultInitializable(i))\n return false;\n\n return true;\n }\n\n \/\/\/ Can the pattern at index i be default initialized?\n bool isDefaultInitializable(unsigned i) const;\n\n \/\/\/ Can the property wrapper be used to provide default initialization?\n bool isDefaultInitializableViaPropertyWrapper(unsigned i) const;\n\n \/\/\/ Does this pattern have a user-provided initializer expression?\n bool isExplicitlyInitialized(unsigned i) const;\n\n \/\/\/ Whether the pattern entry at the given index can generate a string\n \/\/\/ representation of its initializer expression.\n bool hasInitStringRepresentation(unsigned i) const {\n return getPatternList()[i].hasInitStringRepresentation();\n }\n\n SourceLoc getEqualLoc(unsigned i) const;\n\n \/\/\/ When the pattern binding contains only a single variable with no\n \/\/\/ destructuring, retrieve that variable.\n VarDecl *getSingleVar() const;\n\n \/\/\/ Return the first variable initialized by the pattern at the given index.\n VarDecl *getAnchoringVarDecl(unsigned i) const;\n\n bool isStatic() const { return Bits.PatternBindingDecl.IsStatic; }\n void setStatic(bool s) { Bits.PatternBindingDecl.IsStatic = s; }\n SourceLoc getStaticLoc() const { return StaticLoc; }\n \/\/\/ \\returns the way 'static'\/'class' was spelled in the source.\n StaticSpellingKind getStaticSpelling() const {\n return static_cast(\n Bits.PatternBindingDecl.StaticSpelling);\n }\n \/\/\/ \\returns the way 'static'\/'class' should be spelled for this declaration.\n StaticSpellingKind getCorrectStaticSpelling() const;\n\n \/\/\/ Is the pattern binding entry for this variable currently being computed?\n bool isComputingPatternBindingEntry(const VarDecl *vd) const;\n\n \/\/\/ Gets the text of the initializer expression for the pattern entry at the\n \/\/\/ given index, stripping out inactive branches of any #ifs inside the\n \/\/\/ expression.\n StringRef getInitStringRepresentation(unsigned i,\n SmallVectorImpl &scratch) const {\n return getPatternList()[i].getInitStringRepresentation(scratch);\n }\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::PatternBinding;\n }\n\nprivate:\n MutableArrayRef getMutablePatternList() {\n \/\/ Pattern entries are tail allocated.\n return {getTrailingObjects(), getNumPatternEntries()};\n }\n};\n \n\/\/\/ TopLevelCodeDecl - This decl is used as a container for top-level\n\/\/\/ expressions and statements in the main module. It is always a direct\n\/\/\/ child of a SourceFile. The primary reason for building these is to give\n\/\/\/ top-level statements a DeclContext which is distinct from the file itself.\n\/\/\/ This, among other things, makes it easier to distinguish between local\n\/\/\/ top-level variables (which are not live past the end of the statement) and\n\/\/\/ global variables.\nclass TopLevelCodeDecl : public DeclContext, public Decl {\n BraceStmt *Body;\n SourceLoc getLocFromSource() const { return getStartLoc(); }\n friend class Decl;\npublic:\n TopLevelCodeDecl(DeclContext *Parent, BraceStmt *Body = nullptr)\n : DeclContext(DeclContextKind::TopLevelCodeDecl, Parent),\n Decl(DeclKind::TopLevelCode, Parent),\n Body(Body) {}\n\n BraceStmt *getBody() const { return Body; }\n void setBody(BraceStmt *b) { Body = b; }\n\n SourceLoc getStartLoc() const;\n SourceRange getSourceRange() const;\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::TopLevelCode;\n }\n static bool classof(const DeclContext *C) {\n if (auto D = C->getAsDecl())\n return classof(D);\n return false;\n }\n \n using DeclContext::operator new;\n};\n\n\/\/\/ SerializedTopLevelCodeDeclContext - This represents what was originally a\n\/\/\/ TopLevelCodeDecl during serialization. It is preserved only to maintain the\n\/\/\/ correct AST structure and remangling after deserialization.\nclass SerializedTopLevelCodeDeclContext : public SerializedLocalDeclContext {\npublic:\n SerializedTopLevelCodeDeclContext(DeclContext *Parent)\n : SerializedLocalDeclContext(LocalDeclContextKind::TopLevelCodeDecl,\n Parent) {}\n static bool classof(const DeclContext *DC) {\n if (auto LDC = dyn_cast(DC))\n return LDC->getLocalDeclContextKind() ==\n LocalDeclContextKind::TopLevelCodeDecl;\n return false;\n }\n};\n\n\/\/\/ IfConfigDecl - This class represents #if\/#else\/#endif blocks.\n\/\/\/ Active and inactive block members are stored separately, with the intention\n\/\/\/ being that active members will be handed back to the enclosing context.\nclass IfConfigDecl : public Decl {\n \/\/\/ An array of clauses controlling each of the #if\/#elseif\/#else conditions.\n \/\/\/ The array is ASTContext allocated.\n ArrayRef Clauses;\n SourceLoc EndLoc;\n SourceLoc getLocFromSource() const { return Clauses[0].Loc; }\n friend class Decl;\npublic:\n \n IfConfigDecl(DeclContext *Parent, ArrayRef Clauses,\n SourceLoc EndLoc, bool HadMissingEnd)\n : Decl(DeclKind::IfConfig, Parent), Clauses(Clauses), EndLoc(EndLoc)\n {\n Bits.IfConfigDecl.HadMissingEnd = HadMissingEnd;\n }\n\n ArrayRef getClauses() const { return Clauses; }\n\n \/\/\/ Return the active clause, or null if there is no active one.\n const IfConfigClause *getActiveClause() const {\n for (auto &Clause : Clauses)\n if (Clause.isActive) return &Clause;\n return nullptr;\n }\n\n const ArrayRef getActiveClauseElements() const {\n if (auto *Clause = getActiveClause())\n return Clause->Elements;\n return {};\n }\n \n SourceLoc getEndLoc() const { return EndLoc; }\n\n bool hadMissingEnd() const { return Bits.IfConfigDecl.HadMissingEnd; }\n \n SourceRange getSourceRange() const;\n \n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::IfConfig;\n }\n};\n\nclass StringLiteralExpr;\n\nclass PoundDiagnosticDecl : public Decl {\n SourceLoc StartLoc;\n SourceLoc EndLoc;\n StringLiteralExpr *Message;\n SourceLoc getLocFromSource() const { return StartLoc; }\n friend class Decl;\npublic:\n PoundDiagnosticDecl(DeclContext *Parent, bool IsError, SourceLoc StartLoc,\n SourceLoc EndLoc, StringLiteralExpr *Message)\n : Decl(DeclKind::PoundDiagnostic, Parent), StartLoc(StartLoc),\n EndLoc(EndLoc), Message(Message) {\n Bits.PoundDiagnosticDecl.IsError = IsError;\n Bits.PoundDiagnosticDecl.HasBeenEmitted = false; \n }\n\n DiagnosticKind getKind() const {\n return isError() ? DiagnosticKind::Error : DiagnosticKind::Warning;\n }\n\n StringLiteralExpr *getMessage() const { return Message; }\n\n bool isError() const {\n return Bits.PoundDiagnosticDecl.IsError;\n }\n\n bool hasBeenEmitted() const {\n return Bits.PoundDiagnosticDecl.HasBeenEmitted;\n }\n\n void markEmitted() {\n Bits.PoundDiagnosticDecl.HasBeenEmitted = true;\n }\n \n SourceLoc getEndLoc() const { return EndLoc; };\n \n SourceRange getSourceRange() const {\n return SourceRange(StartLoc, EndLoc);\n }\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::PoundDiagnostic;\n }\n};\n \nclass OpaqueTypeDecl;\n\n\/\/\/ ValueDecl - All named decls that are values in the language. These can\n\/\/\/ have a type, etc.\nclass ValueDecl : public Decl {\n DeclName Name;\n SourceLoc NameLoc;\n llvm::PointerIntPair> TypeAndAccess;\n unsigned LocalDiscriminator = 0;\n\n struct {\n \/\/\/ Whether the \"IsObjC\" bit has been computed yet.\n unsigned isObjCComputed : 1;\n\n \/\/\/ Whether this declaration is exposed to Objective-C.\n unsigned isObjC : 1;\n\n \/\/\/ Whether the \"overridden\" declarations have been computed already.\n unsigned hasOverriddenComputed : 1;\n\n \/\/\/ Whether there are any \"overridden\" declarations. The actual overridden\n \/\/\/ declarations are kept in a side table in the ASTContext.\n unsigned hasOverridden : 1;\n\n \/\/\/ Whether the \"isDynamic\" bit has been computed yet.\n unsigned isDynamicComputed : 1;\n\n \/\/\/ Whether this declaration is 'dynamic', meaning that all uses of\n \/\/\/ the declaration will go through an extra level of indirection that\n \/\/\/ allows the entity to be replaced at runtime.\n unsigned isDynamic : 1;\n\n \/\/\/ Whether the \"isFinal\" bit has been computed yet.\n unsigned isFinalComputed : 1;\n\n \/\/\/ Whether this declaration is 'final'. A final class can't be subclassed,\n \/\/\/ a final class member can't be overriden.\n unsigned isFinal : 1;\n\n \/\/\/ Whether the \"isIUO\" bit\" has been computed yet.\n unsigned isIUOComputed : 1;\n\n \/\/\/ Whether this declaration produces an implicitly unwrapped\n \/\/\/ optional result.\n unsigned isIUO : 1;\n } LazySemanticInfo = { };\n\n friend class DynamicallyReplacedDeclRequest;\n friend class OverriddenDeclsRequest;\n friend class IsObjCRequest;\n friend class IsFinalRequest;\n friend class IsDynamicRequest;\n friend class IsImplicitlyUnwrappedOptionalRequest;\n friend class InterfaceTypeRequest;\n friend class CheckRedeclarationRequest;\n friend class Decl;\n SourceLoc getLocFromSource() const { return NameLoc; }\nprotected:\n ValueDecl(DeclKind K,\n llvm::PointerUnion context,\n DeclName name, SourceLoc NameLoc)\n : Decl(K, context), Name(name), NameLoc(NameLoc) {\n Bits.ValueDecl.AlreadyInLookupTable = false;\n Bits.ValueDecl.CheckedRedeclaration = false;\n Bits.ValueDecl.IsUserAccessible = true;\n }\n\n \/\/ MemberLookupTable borrows a bit from this type\n friend class MemberLookupTable;\n bool isAlreadyInLookupTable() {\n return Bits.ValueDecl.AlreadyInLookupTable;\n }\n void setAlreadyInLookupTable(bool value = true) {\n Bits.ValueDecl.AlreadyInLookupTable = value;\n }\n\n \/\/\/ Determine whether we have already checked whether this\n \/\/\/ declaration is a redeclaration.\n bool alreadyCheckedRedeclaration() const {\n return Bits.ValueDecl.CheckedRedeclaration;\n }\n\n \/\/\/ Set whether we have already checked this declaration as a\n \/\/\/ redeclaration.\n void setCheckedRedeclaration() {\n Bits.ValueDecl.CheckedRedeclaration = true;\n }\n\npublic:\n \/\/\/ Return true if this protocol member is a protocol requirement.\n \/\/\/\n \/\/\/ Asserts if this is not a member of a protocol.\n bool isProtocolRequirement() const;\n\n void setUserAccessible(bool Accessible) {\n Bits.ValueDecl.IsUserAccessible = Accessible;\n }\n\n bool isUserAccessible() const {\n return Bits.ValueDecl.IsUserAccessible;\n }\n\n bool hasName() const { return bool(Name); }\n bool isOperator() const { return Name.isOperator(); }\n\n \/\/\/ Retrieve the full name of the declaration.\n DeclName getName() const { return Name; }\n void setName(DeclName name) { Name = name; }\n\n \/\/\/ Retrieve the base name of the declaration, ignoring any argument\n \/\/\/ names.\n DeclBaseName getBaseName() const { return Name.getBaseName(); }\n\n Identifier getBaseIdentifier() const {\n return Name.getBaseIdentifier();\n }\n\n \/\/\/ Generates a DeclNameRef referring to this declaration with as much\n \/\/\/ specificity as possible.\n DeclNameRef createNameRef() const {\n return DeclNameRef(Name);\n }\n\n \/\/\/ Retrieve the name to use for this declaration when interoperating\n \/\/\/ with the Objective-C runtime.\n \/\/\/\n \/\/\/ \\returns A \"selector\" containing the runtime name. For non-method\n \/\/\/ entities (classes, protocols, properties), this operation will\n \/\/\/ return a zero-parameter selector with the appropriate name in its\n \/\/\/ first slot.\n Optional getObjCRuntimeName(\n bool skipIsObjCResolution = false) const;\n\n \/\/\/ Determine whether the given declaration can infer @objc, or the\n \/\/\/ Objective-C name, if used to satisfy the given requirement.\n bool canInferObjCFromRequirement(ValueDecl *requirement);\n\n SourceLoc getNameLoc() const { return NameLoc; }\n\n bool isUsableFromInline() const;\n\n \/\/\/ Returns \\c true if this declaration is *not* intended to be used directly\n \/\/\/ by application developers despite the visibility.\n bool shouldHideFromEditor() const;\n\n bool hasAccess() const {\n return TypeAndAccess.getInt().hasValue();\n }\n\n \/\/\/ Access control is done by Requests.\n friend class AccessLevelRequest;\n\n \/\/\/ Returns the access level specified explicitly by the user, or provided by\n \/\/\/ default according to language rules.\n \/\/\/\n \/\/\/ Most of the time this is not the interesting value to check; access is\n \/\/\/ limited by enclosing scopes per SE-0025. Use #getFormalAccessScope to\n \/\/\/ check if access control is being used consistently, and to take features\n \/\/\/ such as \\c \\@testable and \\c \\@usableFromInline into account.\n \/\/\/\n \/\/\/ \\sa getFormalAccessScope\n \/\/\/ \\sa hasOpenAccess\n AccessLevel getFormalAccess() const;\n\n \/\/\/ Determine whether this Decl has either Private or FilePrivate access,\n \/\/\/ and its DeclContext does not.\n bool isOutermostPrivateOrFilePrivateScope() const;\n\n \/\/\/ Returns the outermost DeclContext from which this declaration can be\n \/\/\/ accessed, or null if the declaration is public.\n \/\/\/\n \/\/\/ This is used when calculating if access control is being used\n \/\/\/ consistently. If \\p useDC is provided (the location where the value is\n \/\/\/ being used), features that affect formal access such as \\c \\@testable are\n \/\/\/ taken into account.\n \/\/\/\n \/\/\/ \\invariant\n \/\/\/ value.isAccessibleFrom(\n \/\/\/ value.getFormalAccessScope().getDeclContext())<\/code>\n \/\/\/\n \/\/\/ If \\p treatUsableFromInlineAsPublic is true, declarations marked with the\n \/\/\/ \\c \\@usableFromInline attribute are treated as public. This is normally\n \/\/\/ false for name lookup and other source language concerns, but true when\n \/\/\/ computing the linkage of generated functions.\n \/\/\/\n \/\/\/ \\sa getFormalAccess\n \/\/\/ \\sa isAccessibleFrom\n \/\/\/ \\sa hasOpenAccess\n AccessScope\n getFormalAccessScope(const DeclContext *useDC = nullptr,\n bool treatUsableFromInlineAsPublic = false) const;\n\n\n \/\/\/ Copy the formal access level and @usableFromInline attribute from\n \/\/\/ \\p source.\n \/\/\/\n \/\/\/ If \\p sourceIsParentContext is true, an access level of \\c private will\n \/\/\/ be copied as \\c fileprivate, to ensure that this declaration will be\n \/\/\/ available everywhere \\p source is.\n void copyFormalAccessFrom(const ValueDecl *source,\n bool sourceIsParentContext = false);\n\n \/\/\/ Returns the access level that actually controls how a declaration should\n \/\/\/ be emitted and may be used.\n \/\/\/\n \/\/\/ This is the access used when making optimization and code generation\n \/\/\/ decisions. It should not be used at the AST or semantic level.\n AccessLevel getEffectiveAccess() const;\n\n void setAccess(AccessLevel access) {\n assert(!hasAccess() && \"access already set\");\n overwriteAccess(access);\n }\n\n \/\/\/ Overwrite the access of this declaration.\n \/\/\/\n \/\/\/ This is needed in the LLDB REPL.\n void overwriteAccess(AccessLevel access) {\n TypeAndAccess.setInt(access);\n }\n\n \/\/\/ Returns true if this declaration is accessible from the given context.\n \/\/\/\n \/\/\/ A private declaration is accessible from any DeclContext within the same\n \/\/\/ source file.\n \/\/\/\n \/\/\/ An internal declaration is accessible from any DeclContext within the same\n \/\/\/ module.\n \/\/\/\n \/\/\/ A public declaration is accessible everywhere.\n \/\/\/\n \/\/\/ If \\p DC is null, returns true only if this declaration is public.\n \/\/\/\n \/\/\/ If \\p forConformance is true, we ignore the visibility of the protocol\n \/\/\/ when evaluating protocol extension members. This language rule allows a\n \/\/\/ protocol extension of a private protocol to provide default\n \/\/\/ implementations for the requirements of a public protocol, even when\n \/\/\/ the default implementations are not visible to name lookup.\n bool isAccessibleFrom(const DeclContext *DC,\n bool forConformance = false) const;\n\n \/\/\/ Returns whether this declaration should be treated as \\c open from\n \/\/\/ \\p useDC. This is very similar to #getFormalAccess, but takes\n \/\/\/ \\c \\@testable into account.\n \/\/\/\n \/\/\/ This is mostly only useful when considering requirements on an override:\n \/\/\/ if the base declaration is \\c open, the override might have to be too.\n bool hasOpenAccess(const DeclContext *useDC) const;\n\n \/\/\/ FIXME: This is deprecated.\n bool isRecursiveValidation() const;\n\n \/\/\/ Retrieve the \"interface\" type of this value, which uses\n \/\/\/ GenericTypeParamType if the declaration is generic. For a generic\n \/\/\/ function, this will have a GenericFunctionType with a\n \/\/\/ GenericSignature inside the type.\n Type getInterfaceType() const;\n bool hasInterfaceType() const;\n\n \/\/\/ Set the interface type for the given value.\n void setInterfaceType(Type type);\n \n \/\/\/ isInstanceMember - Determine whether this value is an instance member\n \/\/\/ of an enum or protocol.\n bool isInstanceMember() const;\n\n \/\/\/ Retrieve the context discriminator for this local value, which\n \/\/\/ is the index of this declaration in the sequence of\n \/\/\/ discriminated declarations with the same name in the current\n \/\/\/ context. Only local functions and variables with getters and\n \/\/\/ setters have discriminators.\n unsigned getLocalDiscriminator() const;\n void setLocalDiscriminator(unsigned index);\n\n \/\/\/ Retrieve the declaration that this declaration overrides, if any.\n ValueDecl *getOverriddenDecl() const;\n\n \/\/\/ Retrieve the declarations that this declaration overrides, if any.\n llvm::TinyPtrVector getOverriddenDecls() const;\n\n \/\/\/ Set the declaration that this declaration overrides.\n void setOverriddenDecl(ValueDecl *overridden) {\n setOverriddenDecls(overridden);\n }\n\n \/\/\/ Set the declarations that this declaration overrides.\n void setOverriddenDecls(ArrayRef overridden);\n\n \/\/\/ Whether the overridden declarations have already been computed.\n bool overriddenDeclsComputed() const;\n\n \/\/\/ Compute the untyped overload signature for this declaration.\n OverloadSignature getOverloadSignature() const;\n\n \/\/\/ Retrieve the type used to describe this entity for the purposes of\n \/\/\/ overload resolution.\n CanType getOverloadSignatureType() const;\n\n \/\/\/ Returns true if the decl requires Objective-C interop.\n \/\/\/\n \/\/\/ This can be true even if there is no 'objc' attribute on the declaration.\n \/\/\/ In that case it was inferred by the type checker and set with a call to\n \/\/\/ markAsObjC().\n bool isObjC() const;\n\n \/\/\/ Note whether this declaration is known to be exposed to Objective-C.\n void setIsObjC(bool Value);\n\n \/\/\/ Is this declaration 'final'?\n bool isFinal() const;\n\n \/\/\/ Is this declaration marked with 'dynamic'?\n bool isDynamic() const;\n\nprivate:\n bool isObjCDynamic() const {\n return isObjC() && isDynamic();\n }\n\n bool isNativeDynamic() const {\n return !isObjC() && isDynamic();\n }\n\n bool isObjCDynamicInGenericClass() const;\n\npublic:\n \/\/\/ Should we use Objective-C method dispatch for this decl.\n bool shouldUseObjCDispatch() const {\n return isObjCDynamic();\n }\n\n \/\/\/ Should we use native dynamic function replacement dispatch for this decl.\n bool shouldUseNativeDynamicDispatch() const {\n return isNativeDynamic();\n }\n\n \/\/\/ Should we use Objective-C category based function replacement for this\n \/\/\/ decl.\n \/\/\/ This is all `@objc dynamic` methods except for such methods in native\n \/\/\/ generic classes. We can't use a category for generic classes so we use\n \/\/\/ native replacement instead (this behavior is only enabled with\n \/\/\/ -enable-implicit-dynamic).\n bool shouldUseObjCMethodReplacement() const;\n\n \/\/\/ Should we use native dynamic function replacement mechanism for this decl.\n \/\/\/ This is all native dynamic methods except for `@objc dynamic` methods in\n \/\/\/ generic classes (see above).\n bool shouldUseNativeMethodReplacement() const;\n\n \/\/\/ Is this a native dynamic function replacement based replacement.\n \/\/\/ This is all @_dynamicReplacement(for:) of native functions and @objc\n \/\/\/ dynamic methods on generic classes (see above).\n bool isNativeMethodReplacement() const;\n\n bool isEffectiveLinkageMoreVisibleThan(ValueDecl *other) const {\n return (std::min(getEffectiveAccess(), AccessLevel::Public) >\n std::min(other->getEffectiveAccess(), AccessLevel::Public));\n }\n\n \/\/\/ Set whether this type is 'dynamic' or not.\n void setIsDynamic(bool value);\n\n \/\/\/ Whether the 'dynamic' bit has been computed already.\n bool isDynamicComputed() const {\n return LazySemanticInfo.isDynamicComputed;\n }\n\n \/\/\/ Returns true if this decl can be found by id-style dynamic lookup.\n bool canBeAccessedByDynamicLookup() const;\n\n \/\/\/ Returns true if this declaration has an implicitly unwrapped optional\n \/\/\/ result. The precise meaning depends on the declaration kind:\n \/\/\/ - for properties, the value is IUO\n \/\/\/ - for subscripts, the element type is IUO\n \/\/\/ - for functions, the result type is IUO\n \/\/\/ - for constructors, the failability kind is IUO\n bool isImplicitlyUnwrappedOptional() const;\n\n \/\/\/ Should only be set on imported and deserialized declarations; parsed\n \/\/\/ declarations compute this lazily via a request.\n void setImplicitlyUnwrappedOptional(bool isIUO) {\n LazySemanticInfo.isIUOComputed = 1;\n LazySemanticInfo.isIUO = isIUO;\n }\n\n \/\/\/ Returns the protocol requirements that this decl conforms to.\n ArrayRef\n getSatisfiedProtocolRequirements(bool Sorted = false) const;\n\n \/\/\/ Determines the kind of access that should be performed by a\n \/\/\/ DeclRefExpr or MemberRefExpr use of this value in the specified\n \/\/\/ context.\n \/\/\/\n \/\/\/ \\param DC The declaration context.\n \/\/\/\n \/\/\/ \\param isAccessOnSelf Whether this is a member access on the implicit\n \/\/\/ 'self' declaration of the declaration context.\n AccessSemantics getAccessSemanticsFromContext(const DeclContext *DC,\n bool isAccessOnSelf) const;\n\n \/\/\/ Determines if a reference to this declaration from a nested function\n \/\/\/ should be treated like a capture of a local value.\n bool isLocalCapture() const;\n\n \/\/\/ Print a reference to the given declaration.\n std::string printRef() const;\n\n \/\/\/ Dump a reference to the given declaration.\n void dumpRef(raw_ostream &os) const;\n\n \/\/\/ Dump a reference to the given declaration.\n SWIFT_DEBUG_DUMPER(dumpRef());\n\n \/\/\/ Returns true if the declaration is a static member of a type.\n \/\/\/\n \/\/\/ This is not necessarily the opposite of \"isInstanceMember()\". Both\n \/\/\/ predicates will be false for declarations that either categorically\n \/\/\/ can't be \"static\" or are in a context where \"static\" doesn't make sense.\n bool isStatic() const;\n\n \/\/\/ Retrieve the location at which we should insert a new attribute or\n \/\/\/ modifier.\n SourceLoc getAttributeInsertionLoc(bool forModifier) const;\n\n static bool classof(const Decl *D) {\n return D->getKind() >= DeclKind::First_ValueDecl &&\n D->getKind() <= DeclKind::Last_ValueDecl;\n }\n \n \/\/\/ True if this is a C function that was imported as a member of a type in\n \/\/\/ Swift.\n bool isImportAsMember() const;\n\n \/\/\/ Returns true if the declaration's interface type is a function type with a\n \/\/\/ curried self parameter.\n bool hasCurriedSelf() const;\n\n \/\/\/ Returns true if the declaration has a parameter list associated with it.\n \/\/\/\n \/\/\/ Note that not all declarations with function interface types have\n \/\/\/ parameter lists, for example an enum element without associated values.\n bool hasParameterList() const;\n\n \/\/\/ Returns the number of curry levels in the declaration's interface type.\n unsigned getNumCurryLevels() const;\n\n \/\/\/ Get the decl for this value's opaque result type, if it has one.\n OpaqueTypeDecl *getOpaqueResultTypeDecl() const;\n\n \/\/\/ Get the representative for this value's opaque result type, if it has one.\n OpaqueReturnTypeRepr *getOpaqueResultTypeRepr() const;\n\n \/\/\/ Retrieve the attribute associating this declaration with a\n \/\/\/ function builder, if there is one.\n CustomAttr *getAttachedFunctionBuilder() const;\n\n \/\/\/ Retrieve the @functionBuilder type attached to this declaration,\n \/\/\/ if there is one.\n Type getFunctionBuilderType() const;\n\n \/\/\/ If this value or its backing storage is annotated\n \/\/\/ @_dynamicReplacement(for: ...), compute the original declaration\n \/\/\/ that this declaration dynamically replaces.\n ValueDecl *getDynamicallyReplacedDecl() const;\n};\n\n\/\/\/ This is a common base class for declarations which declare a type.\nclass TypeDecl : public ValueDecl {\n MutableArrayRef Inherited;\n\nprotected:\n TypeDecl(DeclKind K, llvm::PointerUnion context,\n Identifier name, SourceLoc NameLoc,\n MutableArrayRef inherited) :\n ValueDecl(K, context, name, NameLoc), Inherited(inherited) {}\n\npublic:\n Identifier getName() const { return getBaseIdentifier(); }\n\n \/\/\/ Returns the string for the base name, or \"_\" if this is unnamed.\n StringRef getNameStr() const {\n return hasName() ? getBaseIdentifier().str() : \"_\";\n }\n\n \/\/\/ The type of this declaration's values. For the type of the\n \/\/\/ declaration itself, use getInterfaceType(), which returns a\n \/\/\/ metatype.\n Type getDeclaredInterfaceType() const;\n\n \/\/\/ Retrieve the set of protocols that this type inherits (i.e,\n \/\/\/ explicitly conforms to).\n MutableArrayRef getInherited() { return Inherited; }\n ArrayRef getInherited() const { return Inherited; }\n\n void setInherited(MutableArrayRef i) { Inherited = i; }\n\n static bool classof(const Decl *D) {\n return D->getKind() >= DeclKind::First_TypeDecl &&\n D->getKind() <= DeclKind::Last_TypeDecl;\n }\n\n \/\/\/ Compute an ordering between two type declarations that is ABI-stable.\n static int compare(const TypeDecl *type1, const TypeDecl *type2);\n\n \/\/\/ Compute an ordering between two type declarations that is ABI-stable.\n \/\/\/ This version takes a pointer-to-a-pointer for use with\n \/\/\/ llvm::array_pod_sort() and similar.\n template\n static int compare(T * const* type1, T * const* type2) {\n return compare(*type1, *type2);\n }\n};\n\n\/\/\/ A type declaration that can have generic parameters attached to it. Because\n\/\/\/ it has these generic parameters, it is always a DeclContext.\nclass GenericTypeDecl : public GenericContext, public TypeDecl {\npublic:\n GenericTypeDecl(DeclKind K, DeclContext *DC,\n Identifier name, SourceLoc nameLoc,\n MutableArrayRef inherited,\n GenericParamList *GenericParams);\n\n \/\/ Resolve ambiguity due to multiple base classes.\n using TypeDecl::getASTContext;\n using DeclContext::operator new;\n using TypeDecl::getDeclaredInterfaceType;\n\n static bool classof(const DeclContext *C) {\n if (auto D = C->getAsDecl())\n return classof(D);\n return false;\n }\n static bool classof(const Decl *D) {\n return D->getKind() >= DeclKind::First_GenericTypeDecl &&\n D->getKind() <= DeclKind::Last_GenericTypeDecl;\n }\n};\n\n\/\/\/ OpaqueTypeDecl - This is a declaration of an opaque type. The opaque type\n\/\/\/ is formally equivalent to its underlying type, but abstracts it away from\n\/\/\/ clients of the opaque type, only exposing the type as something conforming\n\/\/\/ to a given set of constraints.\n\/\/\/\n\/\/\/ Currently, opaque types do not normally have an explicit spelling in source\n\/\/\/ code. One is formed implicitly when a declaration is written with an opaque\n\/\/\/ result type, as in:\n\/\/\/\n\/\/\/ func foo() -> some SignedInteger { return 1 }\n\/\/\/\n\/\/\/ The declared type is a special kind of ArchetypeType representing the\n\/\/\/ abstracted underlying type.\nclass OpaqueTypeDecl : public GenericTypeDecl {\n \/\/\/ The original declaration that \"names\" the opaque type. Although a specific\n \/\/\/ opaque type cannot be explicitly named, oapque types can propagate\n \/\/\/ arbitrarily through expressions, so we need to know *which* opaque type is\n \/\/\/ propagated.\n ValueDecl *NamingDecl;\n \n \/\/\/ The generic signature of the opaque interface to the type. This is the\n \/\/\/ outer generic signature with an added generic parameter representing the\n \/\/\/ underlying type.\n GenericSignature OpaqueInterfaceGenericSignature;\n \n \/\/\/ The generic parameter that represents the underlying type.\n GenericTypeParamType *UnderlyingInterfaceType;\n \n \/\/\/ If known, the underlying type and conformances of the opaque type,\n \/\/\/ expressed as a SubstitutionMap for the opaque interface generic signature.\n \/\/\/ This maps types in the interface generic signature to the outer generic\n \/\/\/ signature of the original declaration.\n Optional UnderlyingTypeSubstitutions;\n \n mutable Identifier OpaqueReturnTypeIdentifier;\n \npublic:\n OpaqueTypeDecl(ValueDecl *NamingDecl,\n GenericParamList *GenericParams,\n DeclContext *DC,\n GenericSignature OpaqueInterfaceGenericSignature,\n GenericTypeParamType *UnderlyingInterfaceType);\n \n ValueDecl *getNamingDecl() const { return NamingDecl; }\n \n void setNamingDecl(ValueDecl *D) {\n assert(!NamingDecl && \"already have naming decl\");\n NamingDecl = D;\n }\n\n \/\/\/ Is this opaque type the opaque return type of the given function?\n \/\/\/\n \/\/\/ This is more complex than just checking `getNamingDecl` because the\n \/\/\/ function could also be the getter of a storage declaration.\n bool isOpaqueReturnTypeOfFunction(const AbstractFunctionDecl *func) const;\n\n GenericSignature getOpaqueInterfaceGenericSignature() const {\n return OpaqueInterfaceGenericSignature;\n }\n \n GenericTypeParamType *getUnderlyingInterfaceType() const {\n return UnderlyingInterfaceType;\n }\n \n Optional getUnderlyingTypeSubstitutions() const {\n return UnderlyingTypeSubstitutions;\n }\n \n void setUnderlyingTypeSubstitutions(SubstitutionMap subs) {\n assert(!UnderlyingTypeSubstitutions.hasValue() && \"resetting underlying type?!\");\n UnderlyingTypeSubstitutions = subs;\n }\n \n \/\/ Opaque type decls are currently always implicit\n SourceRange getSourceRange() const { return SourceRange(); }\n \n \/\/ Get the identifier string that can be used to cross-reference unnamed\n \/\/ opaque return types across files.\n Identifier getOpaqueReturnTypeIdentifier() const;\n \n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::OpaqueType;\n }\n static bool classof(const GenericTypeDecl *D) {\n return D->getKind() == DeclKind::OpaqueType;\n }\n static bool classof(const DeclContext *C) {\n if (auto D = C->getAsDecl())\n return classof(D);\n return false;\n }\n};\n\n\/\/\/ TypeAliasDecl - This is a declaration of a typealias, for example:\n\/\/\/\n\/\/\/ typealias Foo = Int\n\/\/\/\n\/\/\/ TypeAliasDecl's always have 'MetatypeType' type.\n\/\/\/\nclass TypeAliasDecl : public GenericTypeDecl {\n friend class UnderlyingTypeRequest;\n \n \/\/\/ The location of the 'typealias' keyword\n SourceLoc TypeAliasLoc;\n\n \/\/\/ The location of the equal '=' token\n SourceLoc EqualLoc;\n\n \/\/\/ The end of the type, valid even when the type cannot be parsed\n SourceLoc TypeEndLoc;\n\n \/\/\/ The location of the right-hand side of the typealias binding\n TypeLoc UnderlyingTy;\n\npublic:\n TypeAliasDecl(SourceLoc TypeAliasLoc, SourceLoc EqualLoc, Identifier Name,\n SourceLoc NameLoc, GenericParamList *GenericParams,\n DeclContext *DC);\n\n SourceLoc getStartLoc() const { return TypeAliasLoc; }\n SourceRange getSourceRange() const;\n\n \/\/\/ Returns the location of the equal '=' token\n SourceLoc getEqualLoc() const {\n return EqualLoc;\n }\n\n void setTypeEndLoc(SourceLoc e) { TypeEndLoc = e; }\n\n \/\/\/ Retrieve the TypeRepr corresponding to the parsed underlying type.\n TypeRepr *getUnderlyingTypeRepr() const {\n return UnderlyingTy.getTypeRepr();\n }\n void setUnderlyingTypeRepr(TypeRepr *repr) {\n UnderlyingTy = repr;\n }\n \n \/\/\/ Retrieve the interface type of the underlying type.\n Type getUnderlyingType() const;\n void setUnderlyingType(Type type);\n\n \/\/\/ Returns the interface type of the underlying type if computed, null\n \/\/\/ otherwise. Should only be used for dumping.\n Type getCachedUnderlyingType() const { return UnderlyingTy.getType(); }\n\n \/\/\/ For generic typealiases, return the unbound generic type.\n UnboundGenericType *getUnboundGenericType() const;\n\n \/\/\/ Retrieve a sugared interface type containing the structure of the interface\n \/\/\/ type before any semantic validation has occured.\n Type getStructuralType() const;\n \n bool isCompatibilityAlias() const {\n return Bits.TypeAliasDecl.IsCompatibilityAlias;\n }\n\n void markAsCompatibilityAlias(bool newValue = true) {\n Bits.TypeAliasDecl.IsCompatibilityAlias = newValue;\n }\n\n \/\/\/ Is this a special debugger variable?\n bool isDebuggerAlias() const { return Bits.TypeAliasDecl.IsDebuggerAlias; }\n void markAsDebuggerAlias(bool isDebuggerAlias) {\n Bits.TypeAliasDecl.IsDebuggerAlias = isDebuggerAlias;\n }\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::TypeAlias;\n }\n static bool classof(const GenericTypeDecl *D) {\n return D->getKind() == DeclKind::TypeAlias;\n }\n static bool classof(const DeclContext *C) {\n if (auto D = C->getAsDecl())\n return classof(D);\n return false;\n }\n};\n\n\/\/\/ Abstract class describing generic type parameters and associated types,\n\/\/\/ whose common purpose is to anchor the abstract type parameter and specify\n\/\/\/ requirements for any corresponding type argument.\nclass AbstractTypeParamDecl : public TypeDecl {\nprotected:\n AbstractTypeParamDecl(DeclKind kind, DeclContext *dc, Identifier name,\n SourceLoc NameLoc)\n : TypeDecl(kind, dc, name, NameLoc, { }) { }\n\npublic:\n \/\/\/ Return the superclass of the generic parameter.\n Type getSuperclass() const;\n\n \/\/\/ Retrieve the set of protocols to which this abstract type\n \/\/\/ parameter conforms.\n ArrayRef getConformingProtocols() const;\n\n static bool classof(const Decl *D) {\n return D->getKind() >= DeclKind::First_AbstractTypeParamDecl &&\n D->getKind() <= DeclKind::Last_AbstractTypeParamDecl;\n }\n};\n\n\/\/\/ A declaration of a generic type parameter.\n\/\/\/\n\/\/\/ A generic type parameter introduces a new, named type parameter along\n\/\/\/ with some set of requirements on any type argument used to realize this\n\/\/\/ type parameter. The requirements involve conformances to specific\n\/\/\/ protocols or inheritance from a specific class type.\n\/\/\/\n\/\/\/ In the following example, 'T' is a generic type parameter with the\n\/\/\/ requirement that the type argument conform to the 'Comparable' protocol.\n\/\/\/\n\/\/\/ \\code\n\/\/\/ func min(x : T, y : T) -> T { ... }\n\/\/\/ \\endcode\nclass GenericTypeParamDecl : public AbstractTypeParamDecl {\npublic:\n static const unsigned InvalidDepth = 0xFFFF;\n\n \/\/\/ Construct a new generic type parameter.\n \/\/\/\n \/\/\/ \\param dc The DeclContext in which the generic type parameter's owner\n \/\/\/ occurs. This should later be overwritten with the actual declaration\n \/\/\/ context that owns the type parameter.\n \/\/\/\n \/\/\/ \\param name The name of the generic parameter.\n \/\/\/ \\param nameLoc The location of the name.\n GenericTypeParamDecl(DeclContext *dc, Identifier name, SourceLoc nameLoc,\n unsigned depth, unsigned index);\n\n \/\/\/ The depth of this generic type parameter, i.e., the number of outer\n \/\/\/ levels of generic parameter lists that enclose this type parameter.\n \/\/\/\n \/\/\/ \\code\n \/\/\/ struct X {\n \/\/\/ func f() { }\n \/\/\/ }\n \/\/\/ \\endcode\n \/\/\/\n \/\/\/ Here 'T' has depth 0 and 'U' has depth 1. Both have index 0.\n unsigned getDepth() const { return Bits.GenericTypeParamDecl.Depth; }\n\n \/\/\/ Set the depth of this generic type parameter.\n \/\/\/\n \/\/\/ \\sa getDepth\n void setDepth(unsigned depth) {\n Bits.GenericTypeParamDecl.Depth = depth;\n assert(Bits.GenericTypeParamDecl.Depth == depth && \"Truncation\");\n }\n\n \/\/\/ The index of this generic type parameter within its generic parameter\n \/\/\/ list.\n \/\/\/\n \/\/\/ \\code\n \/\/\/ struct X {\n \/\/\/ func f() { }\n \/\/\/ }\n \/\/\/ \\endcode\n \/\/\/\n \/\/\/ Here 'T' and 'U' have indexes 0 and 1, respectively. 'V' has index 0.\n unsigned getIndex() const { return Bits.GenericTypeParamDecl.Index; }\n\n SourceLoc getStartLoc() const { return getNameLoc(); }\n SourceRange getSourceRange() const;\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::GenericTypeParam;\n }\n};\n\n\/\/\/ A declaration of an associated type.\n\/\/\/\n\/\/\/ An associated type introduces a new, named type in a protocol that\n\/\/\/ can vary from one conforming type to the next. Associated types have a\n\/\/\/ set of requirements to which the type that replaces it much realize,\n\/\/\/ described via conformance to specific protocols, or inheritance from a\n\/\/\/ specific class type.\n\/\/\/\n\/\/\/ In the following example, 'Element' is an associated type with no\n\/\/\/ requirements.\n\/\/\/\n\/\/\/ \\code\n\/\/\/ protocol Enumerator {\n\/\/\/ typealias Element\n\/\/\/ func getNext() -> Element?\n\/\/\/ }\n\/\/\/ \\endcode\nclass AssociatedTypeDecl : public AbstractTypeParamDecl {\n \/\/\/ The location of the initial keyword.\n SourceLoc KeywordLoc;\n\n \/\/\/ The default definition.\n TypeRepr *DefaultDefinition;\n\n \/\/\/ The where clause attached to the associated type.\n TrailingWhereClause *TrailingWhere;\n\n LazyMemberLoader *Resolver = nullptr;\n uint64_t ResolverContextData;\n\n friend class DefaultDefinitionTypeRequest;\n\npublic:\n AssociatedTypeDecl(DeclContext *dc, SourceLoc keywordLoc, Identifier name,\n SourceLoc nameLoc, TypeRepr *defaultDefinition,\n TrailingWhereClause *trailingWhere);\n AssociatedTypeDecl(DeclContext *dc, SourceLoc keywordLoc, Identifier name,\n SourceLoc nameLoc, TrailingWhereClause *trailingWhere,\n LazyMemberLoader *definitionResolver,\n uint64_t resolverData);\n\n \/\/\/ Get the protocol in which this associated type is declared.\n ProtocolDecl *getProtocol() const {\n return cast(getDeclContext());\n }\n\n \/\/\/ Check if we have a default definition type.\n bool hasDefaultDefinitionType() const {\n \/\/ If we have a TypeRepr, return true immediately without kicking off\n \/\/ a request.\n return DefaultDefinition || getDefaultDefinitionType();\n }\n\n \/\/\/ Retrieve the default definition type.\n Type getDefaultDefinitionType() const;\n\n \/\/\/ Retrieve the default definition as written in the source.\n TypeRepr *getDefaultDefinitionTypeRepr() const {\n return DefaultDefinition;\n }\n\n \/\/\/ Retrieve the trailing where clause for this associated type, if any.\n TrailingWhereClause *getTrailingWhereClause() const { return TrailingWhere; }\n\n \/\/\/ Set the trailing where clause for this associated type.\n void setTrailingWhereClause(TrailingWhereClause *trailingWhereClause) {\n TrailingWhere = trailingWhereClause;\n }\n\n \/\/\/ Retrieve the associated type \"anchor\", which is the associated type\n \/\/\/ declaration that will be used to describe this associated type in the\n \/\/\/ ABI.\n \/\/\/\n \/\/\/ The associated type \"anchor\" is an associated type that does not\n \/\/\/ override any other associated type. There may be several such associated\n \/\/\/ types; select one deterministically.\n AssociatedTypeDecl *getAssociatedTypeAnchor() const;\n\n \/\/\/ Retrieve the (first) overridden associated type declaration, if any.\n AssociatedTypeDecl *getOverriddenDecl() const {\n return cast_or_null(\n AbstractTypeParamDecl::getOverriddenDecl());\n }\n\n \/\/\/ Retrieve the set of associated types overridden by this associated\n \/\/\/ type.\n llvm::TinyPtrVector getOverriddenDecls() const;\n\n SourceLoc getStartLoc() const { return KeywordLoc; }\n SourceRange getSourceRange() const;\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::AssociatedType;\n }\n};\n\nclass MemberLookupTable;\nclass ConformanceLookupTable;\n \n\/\/ Kinds of pointer types.\nenum PointerTypeKind : unsigned {\n PTK_UnsafeMutableRawPointer,\n PTK_UnsafeRawPointer,\n PTK_UnsafeMutablePointer,\n PTK_UnsafePointer,\n PTK_AutoreleasingUnsafeMutablePointer,\n};\n\nstatic inline bool isRawPointerKind(PointerTypeKind PTK) {\n switch (PTK) {\n case PTK_UnsafeMutableRawPointer:\n case PTK_UnsafeRawPointer:\n return true;\n case PTK_UnsafeMutablePointer:\n case PTK_UnsafePointer:\n case PTK_AutoreleasingUnsafeMutablePointer:\n return false;\n }\n\n llvm_unreachable(\"Unhandled PointerTypeKind in switch.\");\n}\n\n\/\/ Kinds of buffer pointer types.\nenum BufferPointerTypeKind : unsigned {\n BPTK_UnsafeMutableRawBufferPointer,\n BPTK_UnsafeRawBufferPointer,\n BPTK_UnsafeMutableBufferPointer,\n BPTK_UnsafeBufferPointer,\n};\n\nenum KeyPathTypeKind : unsigned char {\n KPTK_AnyKeyPath,\n KPTK_PartialKeyPath,\n KPTK_KeyPath,\n KPTK_WritableKeyPath,\n KPTK_ReferenceWritableKeyPath\n};\n\n\/\/\/ NominalTypeDecl - a declaration of a nominal type, like a struct.\nclass NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {\n SourceRange Braces;\n\n \/\/\/ The first extension of this type.\n ExtensionDecl *FirstExtension = nullptr;\n\n \/\/\/ The last extension of this type, used solely for efficient\n \/\/\/ insertion of new extensions.\n ExtensionDecl *LastExtension = nullptr;\n\n \/\/\/ The generation at which we last loaded extensions.\n unsigned ExtensionGeneration;\n \n \/\/\/ Prepare to traverse the list of extensions.\n void prepareExtensions();\n\n \/\/\/ Retrieve the conformance loader (if any), and removing it in the\n \/\/\/ same operation. The caller is responsible for loading the\n \/\/\/ conformances.\n std::pair takeConformanceLoader() {\n if (!Bits.NominalTypeDecl.HasLazyConformances)\n return { nullptr, 0 };\n\n return takeConformanceLoaderSlow();\n }\n\n \/\/\/ Slow path for \\c takeConformanceLoader().\n std::pair takeConformanceLoaderSlow();\n\n \/\/\/ A lookup table containing all of the members of this type and\n \/\/\/ its extensions.\n \/\/\/\n \/\/\/ The table itself is lazily constructed and updated when\n \/\/\/ lookupDirect() is called.\n MemberLookupTable *LookupTable = nullptr;\n\n \/\/\/ Prepare the lookup table to make it ready for lookups.\n void prepareLookupTable();\n\n \/\/\/ Note that we have added a member into the iterable declaration context,\n \/\/\/ so that it can also be added to the lookup table (if needed).\n void addedMember(Decl *member);\n\n \/\/\/ Note that we have added an extension into the nominal type,\n \/\/\/ so that its members can eventually be added to the lookup table.\n void addedExtension(ExtensionDecl *ext);\n\n \/\/\/ A lookup table used to find the protocol conformances of\n \/\/\/ a given nominal type.\n mutable ConformanceLookupTable *ConformanceTable = nullptr;\n\n \/\/\/ Prepare the conformance table.\n void prepareConformanceTable() const;\n\n \/\/\/ Returns the protocol requirements that \\c Member conforms to.\n ArrayRef\n getSatisfiedProtocolRequirementsForMember(const ValueDecl *Member,\n bool Sorted) const;\n\n friend class ASTContext;\n friend class MemberLookupTable;\n friend class ConformanceLookupTable;\n friend class ExtensionDecl;\n friend class DeclContext;\n friend class IterableDeclContext;\n friend class DirectLookupRequest;\n friend ArrayRef\n ValueDecl::getSatisfiedProtocolRequirements(bool Sorted) const;\n\nprotected:\n Type DeclaredTy;\n Type DeclaredInterfaceTy;\n\n NominalTypeDecl(DeclKind K, DeclContext *DC, Identifier name,\n SourceLoc NameLoc,\n MutableArrayRef inherited,\n GenericParamList *GenericParams) :\n GenericTypeDecl(K, DC, name, NameLoc, inherited, GenericParams),\n IterableDeclContext(IterableDeclContextKind::NominalTypeDecl)\n {\n Bits.NominalTypeDecl.AddedImplicitInitializers = false;\n ExtensionGeneration = 0;\n Bits.NominalTypeDecl.HasLazyConformances = false;\n Bits.NominalTypeDecl.IsComputingSemanticMembers = false;\n }\n\n friend class ProtocolType;\n\npublic:\n using GenericTypeDecl::getASTContext;\n\n SourceRange getBraces() const { return Braces; }\n \n void setBraces(SourceRange braces) { Braces = braces; }\n\n \/\/\/ Should this declaration behave as if it must be accessed\n \/\/\/ resiliently, even when we're building a non-resilient module?\n \/\/\/\n \/\/\/ This is used for diagnostics, because we do not want a behavior\n \/\/\/ change between builds with resilience enabled and disabled.\n bool isFormallyResilient() const;\n\n \/\/\/ Do we need to use resilient access patterns outside of this type's\n \/\/\/ resilience domain?\n bool isResilient() const;\n\n \/\/\/ Do we need to use resilient access patterns when accessing this\n \/\/\/ type from the given module?\n bool isResilient(ModuleDecl *M, ResilienceExpansion expansion) const;\n\n \/\/\/ Determine whether we have already attempted to add any\n \/\/\/ implicitly-defined initializers to this declaration.\n bool addedImplicitInitializers() const {\n return Bits.NominalTypeDecl.AddedImplicitInitializers;\n }\n\n \/\/\/ Note that we have attempted to add implicit initializers.\n void setAddedImplicitInitializers() {\n Bits.NominalTypeDecl.AddedImplicitInitializers = true;\n }\n\n \/\/\/ getDeclaredType - Retrieve the type declared by this entity, without\n \/\/\/ any generic parameters bound if this is a generic type.\n Type getDeclaredType() const;\n\n \/\/\/ getDeclaredInterfaceType - Retrieve the type declared by this entity, with\n \/\/\/ generic parameters bound if this is a generic type.\n Type getDeclaredInterfaceType() const;\n\n \/\/\/ Add a new extension to this nominal type.\n void addExtension(ExtensionDecl *extension);\n\n \/\/\/ Retrieve the set of extensions of this type.\n ExtensionRange getExtensions();\n\n \/\/\/ Special-behaviour flags passed to lookupDirect()\n enum class LookupDirectFlags {\n \/\/\/ Whether to include @_implements members.\n \/\/\/ Used by conformance-checking to find special @_implements members.\n IncludeAttrImplements = 1 << 0,\n \/\/\/ Whether to avoid loading lazy members from any new extensions that would otherwise be found\n \/\/\/ by deserialization.\n \/\/\/\n \/\/\/ Used by the module loader to break recursion and as an optimization e.g. when it is known that a\n \/\/\/ particular member declaration will never appear in an extension.\n IgnoreNewExtensions = 1 << 1,\n };\n\n \/\/\/ Find all of the declarations with the given name within this nominal type\n \/\/\/ and its extensions.\n \/\/\/\n \/\/\/ This routine does not look into superclasses, nor does it consider\n \/\/\/ protocols to which the nominal type conforms. Furthermore, the resulting\n \/\/\/ set of declarations has not been filtered for visibility, nor have\n \/\/\/ overridden declarations been removed.\n TinyPtrVector lookupDirect(DeclName name,\n OptionSet flags =\n OptionSet());\n\n \/\/\/ Collect the set of protocols to which this type should implicitly\n \/\/\/ conform, such as AnyObject (for classes).\n void getImplicitProtocols(SmallVectorImpl &protocols);\n\n \/\/\/ Look for conformances of this nominal type to the given\n \/\/\/ protocol.\n \/\/\/\n \/\/\/ \\param module The module from which we initiate the search.\n \/\/\/ FIXME: This is currently unused.\n \/\/\/\n \/\/\/ \\param protocol The protocol whose conformance is requested.\n \/\/\/ \\param conformances Will be populated with the set of protocol\n \/\/\/ conformances found for this protocol.\n \/\/\/\n \/\/\/ \\returns true if any conformances were found. \n bool lookupConformance(\n ModuleDecl *module, ProtocolDecl *protocol,\n SmallVectorImpl &conformances) const;\n\n \/\/\/ Retrieve all of the protocols that this nominal type conforms to.\n SmallVector getAllProtocols() const;\n\n \/\/\/ Retrieve all of the protocol conformances for this nominal type.\n SmallVector getAllConformances(\n bool sorted = false) const;\n\n \/\/\/ Register an externally-created protocol conformance in the\n \/\/\/ conformance lookup table.\n \/\/\/\n \/\/\/ This is used by deserialization of module files to report\n \/\/\/ conformances.\n void registerProtocolConformance(ProtocolConformance *conformance);\n\n void setConformanceLoader(LazyMemberLoader *resolver, uint64_t contextData);\n\n \/\/\/ Is this the decl for Optional?\n bool isOptionalDecl() const;\n\n \/\/\/ Is this a key path type?\n Optional getKeyPathTypeKind() const;\n\n \/\/\/ Retrieve information about this type as a property wrapper.\n PropertyWrapperTypeInfo getPropertyWrapperTypeInfo() const;\n\n \/\/\/ Return a collection of the stored member variables of this type.\n ArrayRef getStoredProperties() const;\n\n \/\/\/ Return a collection of the stored member variables of this type, along\n \/\/\/ with placeholders for unimportable stored properties.\n ArrayRef getStoredPropertiesAndMissingMemberPlaceholders() const;\n\n \/\/\/ Return the range of semantics attributes attached to this NominalTypeDecl.\n auto getSemanticsAttrs() const\n -> decltype(getAttrs().getSemanticsAttrs()) {\n return getAttrs().getSemanticsAttrs();\n }\n\n bool hasSemanticsAttr(StringRef attrValue) const {\n return getAttrs().hasSemanticsAttr(attrValue);\n }\n\n \/\/\/ Whether this declaration has a synthesized memberwise initializer.\n bool hasMemberwiseInitializer() const;\n\n \/\/\/ Retrieves the synthesized memberwise initializer for this declaration,\n \/\/\/ or \\c nullptr if it does not have one.\n ConstructorDecl *getMemberwiseInitializer() const;\n\n \/\/\/ Retrieves the effective memberwise initializer for this declaration, or\n \/\/\/ \\c nullptr if it does not have one.\n \/\/\/\n \/\/\/ An effective memberwise initializer is either a synthesized memberwise\n \/\/\/ initializer or a user-defined initializer with the same type.\n \/\/\/\n \/\/\/ The access level of the memberwise initializer is set to the minimum of:\n \/\/\/ - Public, by default. This enables public nominal types to have public\n \/\/\/ memberwise initializers.\n \/\/\/ - The `public` default is important for synthesized member types, e.g.\n \/\/\/ `TangentVector` structs synthesized during `Differentiable` derived\n \/\/\/ conformances. Manually extending these types to define a public\n \/\/\/ memberwise initializer causes a redeclaration error.\n \/\/\/ - The minimum access level of memberwise-initialized properties in the\n \/\/\/ nominal type declaration.\n \/\/\/\n \/\/\/ Effective memberwise initializers are used only by derived conformances\n \/\/\/ for `Self`-returning protocol requirements like `AdditiveArithmetic.+`.\n \/\/\/ Such derived conformances require memberwise initialization.\n ConstructorDecl *getEffectiveMemberwiseInitializer();\n\n \/\/\/ Whether this declaration has a synthesized zero parameter default\n \/\/\/ initializer.\n bool hasDefaultInitializer() const;\n\n bool isTypeErasedGenericClass() const;\n\n \/\/\/ Retrieves the synthesized zero parameter default initializer for this\n \/\/\/ declaration, or \\c nullptr if it doesn't have one.\n ConstructorDecl *getDefaultInitializer() const;\n\n void synthesizeSemanticMembersIfNeeded(DeclName member);\n\n \/\/ Implement isa\/cast\/dyncast\/etc.\n static bool classof(const Decl *D) {\n return D->getKind() >= DeclKind::First_NominalTypeDecl &&\n D->getKind() <= DeclKind::Last_NominalTypeDecl;\n }\n static bool classof(const GenericTypeDecl *D) {\n return D->getKind() >= DeclKind::First_NominalTypeDecl &&\n D->getKind() <= DeclKind::Last_NominalTypeDecl;\n }\n\n static bool classof(const DeclContext *C) {\n if (auto D = C->getAsDecl())\n return classof(D);\n return false;\n }\n static bool classof(const IterableDeclContext *C) {\n return C->getIterableContextKind()\n == IterableDeclContextKind::NominalTypeDecl;\n }\n static bool classof(const NominalTypeDecl *D) { return true; }\n static bool classof(const ExtensionDecl *D) { return false; }\n};\n\n\/\/\/ This is the declaration of an enum.\n\/\/\/\n\/\/\/ For example:\n\/\/\/\n\/\/\/ \\code\n\/\/\/ enum Bool {\n\/\/\/ case false\n\/\/\/ case true\n\/\/\/ }\n\/\/\/\n\/\/\/ enum Optional {\n\/\/\/ case none\n\/\/\/ case some(T)\n\/\/\/ }\n\/\/\/ \\endcode\n\/\/\/\n\/\/\/ The type of the decl itself is a MetatypeType; use getDeclaredType()\n\/\/\/ to get the declared type (\"Bool\" or \"Optional\" in the above example).\nclass EnumDecl final : public NominalTypeDecl {\n SourceLoc EnumLoc;\n\n enum SemanticInfoFlags : uint8_t {\n \/\/ Is the raw type valid?\n HasComputedRawType = 1 << 0,\n \/\/ Is the complete set of (auto-incremented) raw values available?\n HasFixedRawValues = 1 << 1,\n \/\/ Is the complete set of raw values type checked?\n HasFixedRawValuesAndTypes = 1 << 2,\n };\n \n struct {\n \/\/\/ The raw type and a bit to indicate whether the\n \/\/\/ raw was computed yet or not.\n llvm::PointerIntPair> RawTypeAndFlags;\n \n bool hasRawType() const {\n return RawTypeAndFlags.getInt().contains(HasComputedRawType);\n }\n void cacheRawType(Type ty) {\n auto flags = RawTypeAndFlags.getInt() | HasComputedRawType;\n RawTypeAndFlags.setPointerAndInt(ty, flags);\n }\n \n bool hasFixedRawValues() const {\n return RawTypeAndFlags.getInt().contains(HasFixedRawValues);\n }\n bool hasCheckedRawValues() const {\n return RawTypeAndFlags.getInt().contains(HasFixedRawValuesAndTypes);\n }\n } LazySemanticInfo;\n\n friend class EnumRawValuesRequest;\n friend class EnumRawTypeRequest;\n\npublic:\n EnumDecl(SourceLoc EnumLoc, Identifier Name, SourceLoc NameLoc,\n MutableArrayRef Inherited,\n GenericParamList *GenericParams, DeclContext *DC);\n\n SourceLoc getStartLoc() const { return EnumLoc; }\n SourceRange getSourceRange() const {\n return SourceRange(EnumLoc, getBraces().End);\n }\n\npublic:\n \/\/\/ A range for iterating the elements of an enum.\n using ElementRange = DowncastFilterRange;\n\n \/\/\/ A range for iterating the cases of an enum.\n using CaseRange = DowncastFilterRange;\n\n \/\/\/ Return a range that iterates over all the elements of an enum.\n ElementRange getAllElements() const {\n return ElementRange(getMembers());\n }\n\n unsigned getNumElements() const {\n auto eltRange = getAllElements();\n return std::distance(eltRange.begin(), eltRange.end());\n }\n\n \/\/\/ If this enum has a unique element, return it. A unique element can\n \/\/\/ either hold a value or not, and the existence of one unique element does\n \/\/\/ not imply the existence or non-existence of the opposite unique element.\n EnumElementDecl *getUniqueElement(bool hasValue) const;\n\n \/\/\/ Return a range that iterates over all the cases of an enum.\n CaseRange getAllCases() const {\n return CaseRange(getMembers());\n }\n\n \/\/\/ Insert all of the 'case' element declarations into a DenseSet.\n void getAllElements(llvm::DenseSet &elements) const {\n for (auto elt : getAllElements())\n elements.insert(elt);\n }\n\n \/\/\/ Whether this enum has a raw value type that recursively references itself.\n bool hasCircularRawValue() const;\n \n \/\/\/ Record that this enum has had all of its raw values computed.\n void setHasFixedRawValues();\n \n \/\/ Implement isa\/cast\/dyncast\/etc.\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::Enum;\n }\n static bool classof(const GenericTypeDecl *D) {\n return D->getKind() == DeclKind::Enum;\n }\n static bool classof(const NominalTypeDecl *D) {\n return D->getKind() == DeclKind::Enum;\n }\n static bool classof(const DeclContext *C) {\n if (auto D = C->getAsDecl())\n return classof(D);\n return false;\n }\n static bool classof(const IterableDeclContext *C) {\n auto NTD = dyn_cast(C);\n return NTD && classof(NTD);\n }\n \n \/\/\/ Determine whether this enum declares a raw type in its inheritance clause.\n bool hasRawType() const { return (bool)getRawType(); }\n\n \/\/\/ Retrieve the declared raw type of the enum from its inheritance clause,\n \/\/\/ or null if it has none.\n Type getRawType() const;\n\n \/\/\/ Set the raw type of the enum from its inheritance clause.\n void setRawType(Type rawType) {\n auto flags = LazySemanticInfo.RawTypeAndFlags.getInt();\n LazySemanticInfo.RawTypeAndFlags.setPointerAndInt(\n rawType, flags | HasComputedRawType);\n }\n\n \/\/\/ True if none of the enum cases have associated values.\n \/\/\/\n \/\/\/ Note that this is true for enums with absolutely no cases.\n bool hasOnlyCasesWithoutAssociatedValues() const;\n\n \/\/\/ True if any of the enum cases have availability annotations.\n \/\/\/\n \/\/\/ Note that this is false for enums with absolutely no cases.\n bool hasPotentiallyUnavailableCaseValue() const;\n\n \/\/\/ True if the enum has cases.\n bool hasCases() const {\n return !getAllElements().empty();\n }\n\n \/\/\/ True if the enum is marked 'indirect'.\n bool isIndirect() const {\n return getAttrs().hasAttribute();\n }\n\n \/\/\/ True if the enum can be exhaustively switched within \\p useDC.\n \/\/\/\n \/\/\/ Note that this property is \\e not necessarily true for all children of\n \/\/\/ \\p useDC. In particular, an inlinable function does not get to switch\n \/\/\/ exhaustively over a non-exhaustive enum declared in the same module.\n \/\/\/\n \/\/\/ This is the predicate used when deciding if a switch statement needs a\n \/\/\/ default case. It should not be used for optimization or code generation.\n \/\/\/\n \/\/\/ \\sa isEffectivelyExhaustive\n bool isFormallyExhaustive(const DeclContext *useDC) const;\n\n \/\/\/ True if the enum can be exhaustively switched within a function defined\n \/\/\/ within \\p M, with \\p expansion specifying whether the function is\n \/\/\/ inlinable.\n \/\/\/\n \/\/\/ This is the predicate used when making optimization and code generation\n \/\/\/ decisions. It should not be used at the AST or semantic level.\n \/\/\/\n \/\/\/ \\sa isFormallyExhaustive\n bool isEffectivelyExhaustive(ModuleDecl *M,\n ResilienceExpansion expansion) const;\n};\n\n\/\/\/ StructDecl - This is the declaration of a struct, for example:\n\/\/\/\n\/\/\/ struct Complex { var R : Double, I : Double }\n\/\/\/\n\/\/\/ The type of the decl itself is a MetatypeType; use getDeclaredType()\n\/\/\/ to get the declared type (\"Complex\" in the above example).\nclass StructDecl final : public NominalTypeDecl {\n SourceLoc StructLoc;\n\npublic:\n StructDecl(SourceLoc StructLoc, Identifier Name, SourceLoc NameLoc,\n MutableArrayRef Inherited,\n GenericParamList *GenericParams, DeclContext *DC);\n\n SourceLoc getStartLoc() const { return StructLoc; }\n SourceRange getSourceRange() const {\n return SourceRange(StructLoc, getBraces().End);\n }\n\n \/\/ Implement isa\/cast\/dyncast\/etc.\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::Struct;\n }\n static bool classof(const GenericTypeDecl *D) {\n return D->getKind() == DeclKind::Struct;\n }\n static bool classof(const NominalTypeDecl *D) {\n return D->getKind() == DeclKind::Struct;\n }\n static bool classof(const DeclContext *C) {\n if (auto D = C->getAsDecl())\n return classof(D);\n return false;\n }\n static bool classof(const IterableDeclContext *C) {\n auto NTD = dyn_cast(C);\n return NTD && classof(NTD);\n }\n\n \/\/\/ Does this struct contain unreferenceable storage, such as C fields that\n \/\/\/ cannot be represented in Swift?\n bool hasUnreferenceableStorage() const {\n return Bits.StructDecl.HasUnreferenceableStorage;\n }\n\n void setHasUnreferenceableStorage(bool v) {\n Bits.StructDecl.HasUnreferenceableStorage = v;\n }\n\n bool isCxxNotTriviallyCopyable() const {\n return Bits.StructDecl.IsCxxNotTriviallyCopyable;\n }\n\n void setIsCxxNotTriviallyCopyable(bool v) {\n Bits.StructDecl.IsCxxNotTriviallyCopyable = v;\n }\n};\n\n\/\/\/ This is the base type for AncestryOptions. Each flag describes possible\n\/\/\/ interesting kinds of superclasses that a class may have.\nenum class AncestryFlags : uint8_t {\n \/\/\/ The class or one of its superclasses is @objc.\n ObjC = (1<<0),\n\n \/\/\/ The class or one of its superclasses is @objcMembers.\n ObjCMembers = (1<<1),\n\n \/\/\/ The class or one of its superclasses is generic.\n Generic = (1<<2),\n\n \/\/\/ The class or one of its superclasses is resilient.\n Resilient = (1<<3),\n\n \/\/\/ The class or one of its superclasses has resilient metadata and is in a\n \/\/\/ different resilience domain.\n ResilientOther = (1<<4),\n\n \/\/\/ The class or one of its superclasses is imported from Clang.\n ClangImported = (1<<5),\n\n \/\/\/ The class or one of its superclasses requires stored property initializers.\n RequiresStoredPropertyInits = (1<<6),\n};\n\n\/\/\/ Return type of ClassDecl::checkAncestry(). Describes a set of interesting\n\/\/\/ kinds of superclasses that a class may have.\nusing AncestryOptions = OptionSet;\n\n\/\/\/ ClassDecl - This is the declaration of a class, for example:\n\/\/\/\n\/\/\/ class Complex { var R : Double, I : Double }\n\/\/\/\n\/\/\/ The type of the decl itself is a MetatypeType; use getDeclaredType()\n\/\/\/ to get the declared type (\"Complex\" in the above example).\nclass ClassDecl final : public NominalTypeDecl {\n class ObjCMethodLookupTable;\n\n SourceLoc ClassLoc;\n ObjCMethodLookupTable *ObjCMethodLookup = nullptr;\n\n \/\/\/ Create the Objective-C member lookup table.\n void createObjCMethodLookup();\n\n struct {\n \/\/\/ The superclass decl and a bit to indicate whether the\n \/\/\/ superclass was computed yet or not.\n llvm::PointerIntPair SuperclassDecl;\n\n \/\/\/ The superclass type and a bit to indicate whether the\n \/\/\/ superclass was computed yet or not.\n llvm::PointerIntPair SuperclassType;\n } LazySemanticInfo;\n\n bool hasForcedEmittedMembers() const {\n return Bits.ClassDecl.HasForcedEmittedMembers;\n }\n\n void setHasForcedEmittedMembers() {\n Bits.ClassDecl.HasForcedEmittedMembers = true;\n }\n\n Optional getCachedInheritsSuperclassInitializers() const {\n if (Bits.ClassDecl.ComputedInheritsSuperclassInits)\n return Bits.ClassDecl.InheritsSuperclassInits;\n\n return None;\n }\n\n Optional getCachedHasMissingDesignatedInitializers() const {\n if (!Bits.ClassDecl.ComputedHasMissingDesignatedInitializers) {\n \/\/ Force loading all the members, which will add this attribute if any of\n \/\/ members are determined to be missing while loading.\n auto mutableThis = const_cast(this);\n (void)mutableThis->lookupDirect(DeclBaseName::createConstructor());\n }\n\n if (Bits.ClassDecl.ComputedHasMissingDesignatedInitializers)\n return Bits.ClassDecl.HasMissingDesignatedInitializers;\n\n return None;\n }\n\n void setHasMissingDesignatedInitializers(bool value) {\n Bits.ClassDecl.HasMissingDesignatedInitializers = value;\n Bits.ClassDecl.ComputedHasMissingDesignatedInitializers = true;\n }\n\n \/\/\/ Marks that this class inherits convenience initializers from its\n \/\/\/ superclass.\n void setInheritsSuperclassInitializers(bool value) {\n Bits.ClassDecl.InheritsSuperclassInits = value;\n Bits.ClassDecl.ComputedInheritsSuperclassInits = true;\n }\n\n friend class SuperclassDeclRequest;\n friend class SuperclassTypeRequest;\n friend class EmittedMembersRequest;\n friend class HasMissingDesignatedInitializersRequest;\n friend class InheritsSuperclassInitializersRequest;\n\npublic:\n ClassDecl(SourceLoc ClassLoc, Identifier Name, SourceLoc NameLoc,\n MutableArrayRef Inherited,\n GenericParamList *GenericParams, DeclContext *DC);\n\n SourceLoc getStartLoc() const { return ClassLoc; }\n SourceRange getSourceRange() const {\n return SourceRange(ClassLoc, getBraces().End);\n }\n\n \/\/\/ Determine whether the member area of this class's metadata (which consists\n \/\/\/ of field offsets and vtable entries) is to be considered opaque by clients.\n \/\/\/\n \/\/\/ Note that even @_fixed_layout classes have resilient metadata if they are\n \/\/\/ in a resilient module.\n bool hasResilientMetadata() const;\n\n \/\/\/ Determine whether this class has resilient metadata when accessed from the\n \/\/\/ given module and resilience expansion.\n bool hasResilientMetadata(ModuleDecl *M, ResilienceExpansion expansion) const;\n\n \/\/\/ Determine whether this class has a superclass.\n bool hasSuperclass() const { return (bool)getSuperclassDecl(); }\n\n \/\/\/ Retrieve the superclass of this class, or null if there is no superclass.\n Type getSuperclass() const;\n\n \/\/\/ Retrieve the ClassDecl for the superclass of this class, or null if there\n \/\/\/ is no superclass.\n ClassDecl *getSuperclassDecl() const;\n\n \/\/\/ Check if this class is a superclass or equal to the given class.\n bool isSuperclassOf(ClassDecl *other) const;\n\n \/\/\/ Set the superclass of this class.\n void setSuperclass(Type superclass);\n\n \/\/\/ Whether this class has a circular reference in its inheritance hierarchy.\n bool hasCircularInheritance() const;\n\n \/\/\/ Walk this class and all of the superclasses of this class, transitively,\n \/\/\/ invoking the callback function for each class.\n \/\/\/\n \/\/\/ \\param fn The callback function that will be invoked for each superclass.\n \/\/\/ It can return \\c Continue to continue the traversal. Returning\n \/\/\/ \\c SkipChildren halts the search and returns \\c false, while returning\n \/\/\/ \\c Stop halts the search and returns \\c true.\n \/\/\/\n \/\/\/ \\returns \\c true if \\c fn returned \\c Stop for any class, \\c false\n \/\/\/ otherwise.\n bool walkSuperclasses(\n llvm::function_ref fn) const;\n\n \/\/\/\/ Whether this class requires all of its stored properties to\n \/\/\/\/ have initializers in the class definition.\n bool requiresStoredPropertyInits() const {\n return checkAncestry(AncestryFlags::RequiresStoredPropertyInits);\n }\n\n \/\/\/ \\see getForeignClassKind\n enum class ForeignKind : uint8_t {\n \/\/\/ A normal Swift or Objective-C class.\n Normal = 0,\n \/\/\/ An imported Core Foundation type. These are AnyObject-compatible but\n \/\/\/ do not have runtime metadata.\n CFType,\n \/\/\/ An imported Objective-C type whose class and metaclass symbols are not\n \/\/\/ both available at link-time but can be accessed through the Objective-C\n \/\/\/ runtime.\n RuntimeOnly\n };\n\n \/\/\/ Whether this class is \"foreign\", meaning that it is implemented\n \/\/\/ by a runtime that Swift does not have first-class integration\n \/\/\/ with. This generally means that:\n \/\/\/ - class data is either abstracted or cannot be made to\n \/\/\/ fit with Swift's metatype schema, and\/or\n \/\/\/ - there is no facility for subclassing or adding polymorphic\n \/\/\/ methods to the class.\n \/\/\/\n \/\/\/ We may find ourselves wanting to break this bit into more\n \/\/\/ precise chunks later.\n ForeignKind getForeignClassKind() const {\n return static_cast(Bits.ClassDecl.RawForeignKind);\n }\n void setForeignClassKind(ForeignKind kind) {\n Bits.ClassDecl.RawForeignKind = static_cast(kind);\n }\n\n \/\/\/ Returns true if this class is any kind of \"foreign class\".\n \/\/\/\n \/\/\/ \\see getForeignClassKind\n bool isForeign() const {\n return getForeignClassKind() != ForeignKind::Normal;\n }\n\n \/\/\/ Returns true if the class has designated initializers that are not listed\n \/\/\/ in its members.\n \/\/\/\n \/\/\/ This can occur, for example, if the class is an Objective-C class with\n \/\/\/ initializers that cannot be represented in Swift.\n bool hasMissingDesignatedInitializers() const;\n\n \/\/\/ Returns true if the class has missing members that require vtable entries.\n \/\/\/\n \/\/\/ In this case, the class cannot be subclassed, because we cannot construct\n \/\/\/ the vtable for the subclass.\n bool hasMissingVTableEntries() const;\n\n void setHasMissingVTableEntries(bool newValue = true) {\n Bits.ClassDecl.ComputedHasMissingVTableEntries = 1;\n Bits.ClassDecl.HasMissingVTableEntries = newValue;\n }\n\n \/\/\/ Returns true if this class cannot be used with weak or unowned\n \/\/\/ references.\n \/\/\/ \n \/\/\/ Note that this is true if this class or any of its ancestor classes\n \/\/\/ are marked incompatible.\n bool isIncompatibleWithWeakReferences() const;\n\n void setIsIncompatibleWithWeakReferences(bool newValue = true) {\n Bits.ClassDecl.IsIncompatibleWithWeakReferences = newValue;\n }\n\n \/\/\/ Find a method of a class that overrides a given method.\n \/\/\/ Return nullptr, if no such method exists.\n AbstractFunctionDecl *findOverridingDecl(\n const AbstractFunctionDecl *method) const;\n\n \/\/\/ Find a method implementation which will be used when a given method\n \/\/\/ is invoked on an instance of this class. This implementation may stem\n \/\/\/ either from a class itself or its direct or indirect superclasses.\n AbstractFunctionDecl *findImplementingMethod(\n const AbstractFunctionDecl *method) const;\n \n \/\/\/ Retrieve the destructor for this class.\n DestructorDecl *getDestructor() const;\n\n \/\/\/ Determine whether this class inherits the convenience initializers\n \/\/\/ from its superclass.\n bool inheritsSuperclassInitializers() const;\n\n \/\/\/ Walks the class hierarchy starting from this class, checking various\n \/\/\/ conditions.\n AncestryOptions checkAncestry() const;\n\n \/\/\/ Check if the class has ancestry of the given kind.\n bool checkAncestry(AncestryFlags flag) const {\n return checkAncestry().contains(flag);\n }\n\n \/\/\/ The type of metaclass to use for a class.\n enum class MetaclassKind : uint8_t {\n ObjC,\n SwiftStub,\n };\n\n \/\/\/ Determine which sort of metaclass to use for this class\n MetaclassKind getMetaclassKind() const;\n\n \/\/\/ Retrieve the name to use for this class when interoperating with\n \/\/\/ the Objective-C runtime.\n StringRef getObjCRuntimeName(llvm::SmallVectorImpl &buffer) const;\n\n using NominalTypeDecl::lookupDirect;\n\n \/\/\/ Look in this class and its extensions (but not any of its protocols or\n \/\/\/ superclasses) for declarations with a given Objective-C selector.\n \/\/\/\n \/\/\/ Note that this can find methods, initializers, deinitializers,\n \/\/\/ getters, and setters.\n \/\/\/\n \/\/\/ \\param selector The Objective-C selector of the method we're\n \/\/\/ looking for.\n \/\/\/\n \/\/\/ \\param isInstance Whether we are looking for an instance method\n \/\/\/ (vs. a class method).\n TinyPtrVector lookupDirect(ObjCSelector selector,\n bool isInstance);\n\n \/\/\/ Record the presence of an @objc method with the given selector.\n void recordObjCMethod(AbstractFunctionDecl *method, ObjCSelector selector);\n\n \/\/\/ Get all the members of this class, synthesizing any implicit members\n \/\/\/ that appear in the vtable if needed.\n DeclRange getEmittedMembers() const;\n\n \/\/ Implement isa\/cast\/dyncast\/etc.\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::Class;\n }\n static bool classof(const GenericTypeDecl *D) {\n return D->getKind() == DeclKind::Class;\n }\n static bool classof(const NominalTypeDecl *D) {\n return D->getKind() == DeclKind::Class;\n }\n static bool classof(const DeclContext *C) {\n if (auto D = C->getAsDecl())\n return classof(D);\n return false;\n }\n static bool classof(const IterableDeclContext *C) {\n auto NTD = dyn_cast(C);\n return NTD && classof(NTD);\n }\n \n \/\/\/ Returns true if the decl uses the Objective-C generics model.\n \/\/\/\n \/\/\/ This is true of imported Objective-C classes.\n bool usesObjCGenericsModel() const {\n return hasClangNode() && isGenericContext() && isObjC();\n }\n \n \/\/\/ True if the class is known to be implemented in Swift.\n bool hasKnownSwiftImplementation() const {\n return !hasClangNode();\n }\n};\n\n\n\/\/\/ Describes whether a requirement refers to 'Self', for use in the\n\/\/\/ is-inheritable and is-available-existential checks.\nstruct SelfReferenceKind {\n bool result;\n bool parameter;\n bool requirement;\n bool other;\n\n \/\/\/ The type does not refer to 'Self' at all.\n static SelfReferenceKind None() {\n return SelfReferenceKind(false, false, false, false);\n }\n\n \/\/\/ The type refers to 'Self', but only as the result type of a method.\n static SelfReferenceKind Result() {\n return SelfReferenceKind(true, false, false, false);\n }\n\n \/\/\/ The type refers to 'Self', but only as the parameter type of a method.\n static SelfReferenceKind Parameter() {\n return SelfReferenceKind(false, true, false, false);\n }\n\n \/\/\/ The type refers to 'Self' within a same-type requiement.\n static SelfReferenceKind Requirement() {\n return SelfReferenceKind(false, false, true, false);\n }\n\n \/\/\/ The type refers to 'Self' in a position that is invariant.\n static SelfReferenceKind Other() {\n return SelfReferenceKind(false, false, false, true);\n }\n\n SelfReferenceKind flip() const {\n return SelfReferenceKind(parameter, result, requirement, other);\n }\n\n SelfReferenceKind operator|=(SelfReferenceKind kind) {\n result |= kind.result;\n requirement |= kind.requirement;\n parameter |= kind.parameter;\n other |= kind.other;\n return *this;\n }\n\n operator bool() const {\n return result || parameter || requirement || other;\n }\n\nprivate:\n SelfReferenceKind(bool result, bool parameter, bool requirement, bool other)\n : result(result), parameter(parameter), requirement(requirement),\n other(other) { }\n};\n\n\/\/\/ The set of known protocols for which derived conformances are supported.\nenum class KnownDerivableProtocolKind : uint8_t {\n RawRepresentable,\n OptionSet,\n CaseIterable,\n Comparable,\n Equatable,\n Hashable,\n BridgedNSError,\n CodingKey,\n Encodable,\n Decodable,\n AdditiveArithmetic,\n Differentiable,\n};\n\n\/\/\/ ProtocolDecl - A declaration of a protocol, for example:\n\/\/\/\n\/\/\/ protocol Drawable {\n\/\/\/ func draw()\n\/\/\/ }\n\/\/\/\n\/\/\/ Every protocol has an implicitly-created 'Self' generic parameter that\n\/\/\/ stands for a type that conforms to the protocol. For example,\n\/\/\/\n\/\/\/ protocol Cloneable {\n\/\/\/ func clone() -> Self\n\/\/\/ }\n\/\/\/\nclass ProtocolDecl final : public NominalTypeDecl {\n SourceLoc ProtocolLoc;\n\n ArrayRef InheritedProtocols;\n\n struct {\n \/\/\/ The superclass decl and a bit to indicate whether the\n \/\/\/ superclass was computed yet or not.\n llvm::PointerIntPair SuperclassDecl;\n\n \/\/\/ The superclass type and a bit to indicate whether the\n \/\/\/ superclass was computed yet or not.\n llvm::PointerIntPair SuperclassType;\n } LazySemanticInfo;\n\n \/\/\/ The generic signature representing exactly the new requirements introduced\n \/\/\/ by this protocol.\n const Requirement *RequirementSignature = nullptr;\n\n \/\/\/ Returns the cached result of \\c requiresClass or \\c None if it hasn't yet\n \/\/\/ been computed.\n Optional getCachedRequiresClass() const {\n if (Bits.ProtocolDecl.RequiresClassValid)\n return Bits.ProtocolDecl.RequiresClass;\n\n return None;\n }\n\n \/\/\/ Caches the result of \\c requiresClass\n void setCachedRequiresClass(bool requiresClass) {\n Bits.ProtocolDecl.RequiresClassValid = true;\n Bits.ProtocolDecl.RequiresClass = requiresClass;\n }\n\n \/\/\/ Returns the cached result of \\c existentialConformsToSelf or \\c None if it\n \/\/\/ hasn't yet been computed.\n Optional getCachedExistentialConformsToSelf() const {\n if (Bits.ProtocolDecl.ExistentialConformsToSelfValid)\n return Bits.ProtocolDecl.ExistentialConformsToSelf;\n\n return None;\n }\n\n \/\/\/ Caches the result of \\c existentialConformsToSelf\n void setCachedExistentialConformsToSelf(bool result) {\n Bits.ProtocolDecl.ExistentialConformsToSelfValid = true;\n Bits.ProtocolDecl.ExistentialConformsToSelf = result;\n }\n\n \/\/\/ Returns the cached result of \\c existentialTypeSupported or \\c None if it\n \/\/\/ hasn't yet been computed.\n Optional getCachedExistentialTypeSupported() {\n if (Bits.ProtocolDecl.ExistentialTypeSupportedValid)\n return Bits.ProtocolDecl.ExistentialTypeSupported;\n\n return None;\n }\n\n \/\/\/ Caches the result of \\c existentialTypeSupported\n void setCachedExistentialTypeSupported(bool supported) {\n Bits.ProtocolDecl.ExistentialTypeSupportedValid = true;\n Bits.ProtocolDecl.ExistentialTypeSupported = supported;\n }\n\n bool hasLazyRequirementSignature() const {\n return Bits.ProtocolDecl.HasLazyRequirementSignature;\n }\n\n friend class SuperclassDeclRequest;\n friend class SuperclassTypeRequest;\n friend class RequirementSignatureRequest;\n friend class ProtocolRequiresClassRequest;\n friend class ExistentialConformsToSelfRequest;\n friend class ExistentialTypeSupportedRequest;\n friend class InheritedProtocolsRequest;\n \npublic:\n ProtocolDecl(DeclContext *DC, SourceLoc ProtocolLoc, SourceLoc NameLoc,\n Identifier Name, MutableArrayRef Inherited,\n TrailingWhereClause *TrailingWhere);\n\n using Decl::getASTContext;\n\n \/\/\/ Retrieve the set of protocols inherited from this protocol.\n ArrayRef getInheritedProtocols() const;\n\n \/\/\/ Determine whether this protocol has a superclass.\n bool hasSuperclass() const { return (bool)getSuperclassDecl(); }\n\n \/\/\/ Retrieve the superclass of this protocol, or null if there is no superclass.\n Type getSuperclass() const;\n\n \/\/\/ Retrieve the ClassDecl for the superclass of this protocol, or null if there\n \/\/\/ is no superclass.\n ClassDecl *getSuperclassDecl() const;\n\n \/\/\/ Set the superclass of this protocol.\n void setSuperclass(Type superclass);\n\n \/\/\/ Retrieve the set of AssociatedTypeDecl members of this protocol; this\n \/\/\/ saves loading the set of members in cases where there's no possibility of\n \/\/\/ a protocol having nested types (ObjC protocols).\n llvm::TinyPtrVector getAssociatedTypeMembers() const;\n\n \/\/\/ Returns a protocol requirement with the given name, or nullptr if the\n \/\/\/ name has multiple overloads, or no overloads at all.\n ValueDecl *getSingleRequirement(DeclName name) const;\n\n \/\/\/ Returns an associated type with the given name, or nullptr if one does\n \/\/\/ not exist.\n AssociatedTypeDecl *getAssociatedType(Identifier name) const;\n\n \/\/\/ Walk this protocol and all of the protocols inherited by this protocol,\n \/\/\/ transitively, invoking the callback function for each protocol.\n \/\/\/\n \/\/\/ \\param fn The callback function that will be invoked for each inherited\n \/\/\/ protocol. It can return \\c Continue to continue the traversal,\n \/\/\/ \\c SkipChildren to avoid visiting the children of the given protocol\n \/\/\/ but continue the search, and \\c Stop to halt the search.\n \/\/\/\n \/\/\/ \\returns \\c true if \\c fn returned \\c Stop for any protocol, \\c false\n \/\/\/ otherwise.\n bool walkInheritedProtocols(\n llvm::function_ref fn) const;\n\n \/\/\/ Determine whether this protocol inherits from the given (\"super\")\n \/\/\/ protocol.\n bool inheritsFrom(const ProtocolDecl *Super) const;\n \n ProtocolType *getDeclaredType() const {\n return reinterpret_cast(\n NominalTypeDecl::getDeclaredType().getPointer());\n }\n \n SourceLoc getStartLoc() const { return ProtocolLoc; }\n SourceRange getSourceRange() const {\n return SourceRange(ProtocolLoc, getBraces().End);\n }\n\n \/\/\/ True if this protocol can only be conformed to by class types.\n bool requiresClass() const;\n\n \/\/\/ Determine whether an existential conforming to this protocol can be\n \/\/\/ matched with a generic type parameter constrained to this protocol.\n \/\/\/ This is only permitted if there is nothing \"non-trivial\" that we\n \/\/\/ can do with the metatype, which means the protocol must not have\n \/\/\/ any static methods and must be declared @objc.\n bool existentialConformsToSelf() const;\n\n \/\/\/ Does this protocol require a self-conformance witness table?\n bool requiresSelfConformanceWitnessTable() const;\n\n \/\/\/ Find direct Self references within the given requirement.\n \/\/\/\n \/\/\/ \\param allowCovariantParameters If true, 'Self' is assumed to be\n \/\/\/ covariant anywhere; otherwise, only in the return type of the top-level\n \/\/\/ function type.\n \/\/\/\n \/\/\/ \\param skipAssocTypes If true, associated types of 'Self' are ignored;\n \/\/\/ otherwise, they count as an 'other' usage of 'Self'.\n SelfReferenceKind findProtocolSelfReferences(const ValueDecl *decl,\n bool allowCovariantParameters,\n bool skipAssocTypes) const;\n\n \/\/\/ Determine whether we are allowed to refer to an existential type\n \/\/\/ conforming to this protocol. This is only permitted if the type of\n \/\/\/ the member does not contain any associated types, and does not\n \/\/\/ contain 'Self' in 'parameter' or 'other' position.\n bool isAvailableInExistential(const ValueDecl *decl) const;\n\n \/\/\/ Determine whether we are allowed to refer to an existential type\n \/\/\/ conforming to this protocol. This is only permitted if the types of\n \/\/\/ all the members do not contain any associated types, and do not\n \/\/\/ contain 'Self' in 'parameter' or 'other' position.\n bool existentialTypeSupported() const;\n\nprivate:\n void computeKnownProtocolKind() const;\n\n bool areInheritedProtocolsValid() const {\n return Bits.ProtocolDecl.InheritedProtocolsValid;\n }\n void setInheritedProtocolsValid() {\n Bits.ProtocolDecl.InheritedProtocolsValid = true;\n }\n\npublic:\n \/\/\/ If this is known to be a compiler-known protocol, returns the kind.\n \/\/\/ Otherwise returns None.\n Optional getKnownProtocolKind() const {\n if (Bits.ProtocolDecl.KnownProtocol == 0)\n computeKnownProtocolKind();\n\n if (Bits.ProtocolDecl.KnownProtocol == 1)\n return None;\n \n return static_cast(Bits.ProtocolDecl.KnownProtocol - 2);\n }\n\n Optional getKnownDerivableProtocolKind() const;\n\n \/\/\/ Check whether this protocol is of a specific, known protocol kind.\n bool isSpecificProtocol(KnownProtocolKind kind) const {\n if (auto knownKind = getKnownProtocolKind())\n return *knownKind == kind;\n\n return false;\n }\n\n \/\/\/ Whether this protocol has a circular reference in its list of inherited\n \/\/\/ protocols.\n bool hasCircularInheritedProtocols() const;\n\n \/\/\/ Returns true if the protocol has requirements that are not listed in its\n \/\/\/ members.\n \/\/\/\n \/\/\/ This can occur, for example, if the protocol is an Objective-C protocol\n \/\/\/ with requirements that cannot be represented in Swift.\n bool hasMissingRequirements() const {\n (void)getMembers();\n return Bits.ProtocolDecl.HasMissingRequirements;\n }\n\n void setHasMissingRequirements(bool newValue) {\n Bits.ProtocolDecl.HasMissingRequirements = newValue;\n }\n\n \/\/\/ Returns the default type witness for an associated type, or a null\n \/\/\/ type if there is no default.\n Type getDefaultTypeWitness(AssociatedTypeDecl *assocType) const;\n\n \/\/\/ Set the default type witness for an associated type.\n void setDefaultTypeWitness(AssociatedTypeDecl *assocType, Type witness);\n\n \/\/\/ Returns the default witness for a requirement, or nullptr if there is\n \/\/\/ no default.\n Witness getDefaultWitness(ValueDecl *requirement) const;\n\n \/\/\/ Record the default witness for a requirement.\n void setDefaultWitness(ValueDecl *requirement, Witness witness);\n\n \/\/\/ Returns the default associated conformance witness for an associated\n \/\/\/ type, or \\c None if there is no default.\n ProtocolConformanceRef\n getDefaultAssociatedConformanceWitness(CanType association,\n ProtocolDecl *requirement) const;\n\n \/\/\/ Set the default associated conformance witness for the given\n \/\/\/ associated conformance.\n void setDefaultAssociatedConformanceWitness(\n CanType association,\n ProtocolDecl *requirement,\n ProtocolConformanceRef conformance);\n\n \/\/\/ Retrieve the name to use for this protocol when interoperating\n \/\/\/ with the Objective-C runtime.\n StringRef getObjCRuntimeName(llvm::SmallVectorImpl &buffer) const;\n\n \/\/\/ Retrieve the requirements that describe this protocol.\n \/\/\/\n \/\/\/ These are the requirements including any inherited protocols\n \/\/\/ and conformances for associated types that are introduced in this\n \/\/\/ protocol. Requirements implied via any other protocol (e.g., inherited\n \/\/\/ protocols of the inherited protocols) are not mentioned. The conformance\n \/\/\/ requirements listed here become entries in the witness table.\n ArrayRef getRequirementSignature() const;\n\n \/\/\/ Is the requirement signature currently being computed?\n bool isComputingRequirementSignature() const;\n\n \/\/\/ Has the requirement signature been computed yet?\n bool isRequirementSignatureComputed() const {\n return RequirementSignature != nullptr;\n }\n\n void setRequirementSignature(ArrayRef requirements);\n\n void setLazyRequirementSignature(LazyMemberLoader *lazyLoader,\n uint64_t requirementSignatureData);\n\nprivate:\n ArrayRef getCachedRequirementSignature() const;\n\npublic:\n \/\/ Implement isa\/cast\/dyncast\/etc.\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::Protocol;\n }\n static bool classof(const GenericTypeDecl *D) {\n return D->getKind() == DeclKind::Protocol;\n }\n static bool classof(const NominalTypeDecl *D) {\n return D->getKind() == DeclKind::Protocol;\n }\n static bool classof(const DeclContext *C) {\n if (auto D = C->getAsDecl())\n return classof(D);\n return false;\n }\n static bool classof(const IterableDeclContext *C) {\n auto NTD = dyn_cast(C);\n return NTD && classof(NTD);\n }\n};\n\n\/\/\/ AbstractStorageDecl - This is the common superclass for VarDecl and\n\/\/\/ SubscriptDecl, representing potentially settable memory locations.\nclass AbstractStorageDecl : public ValueDecl {\n friend class SetterAccessLevelRequest;\n friend class IsGetterMutatingRequest;\n friend class IsSetterMutatingRequest;\n friend class OpaqueReadOwnershipRequest;\n friend class StorageImplInfoRequest;\n friend class RequiresOpaqueAccessorsRequest;\n friend class RequiresOpaqueModifyCoroutineRequest;\n friend class SynthesizeAccessorRequest;\n\npublic:\n static const size_t MaxNumAccessors = 255;\nprivate:\n \/\/\/ A record of the accessors for the declaration.\n class alignas(1 << 3) AccessorRecord final :\n private llvm::TrailingObjects {\n friend TrailingObjects;\n\n using AccessorIndex = uint8_t;\n static const AccessorIndex InvalidIndex = 0;\n\n \/\/\/ The range of the braces around the accessor clause.\n SourceRange Braces;\n\n \/\/\/ The number of accessors currently stored in this record.\n AccessorIndex NumAccessors;\n\n \/\/\/ The storage capacity of this record for accessors. Always includes\n \/\/\/ enough space for adding opaque accessors to the record, which are the\n \/\/\/ only accessors that should ever be added retroactively; hence this\n \/\/\/ field is only here for the purposes of safety checks.\n AccessorIndex AccessorsCapacity;\n\n \/\/\/ Either 0, meaning there is no registered accessor of the given kind,\n \/\/\/ or the index+1 of the accessor in the accessors array.\n AccessorIndex AccessorIndices[NumAccessorKinds];\n\n AccessorRecord(SourceRange braces,\n ArrayRef accessors,\n AccessorIndex accessorsCapacity);\n public:\n static AccessorRecord *create(ASTContext &ctx, SourceRange braces,\n ArrayRef accessors);\n\n SourceRange getBracesRange() const { return Braces; }\n\n inline AccessorDecl *getAccessor(AccessorKind kind) const;\n\n ArrayRef getAllAccessors() const {\n return { getTrailingObjects(), NumAccessors };\n }\n\n void addOpaqueAccessor(AccessorDecl *accessor);\n\n private:\n MutableArrayRef getAccessorsBuffer() {\n return { getTrailingObjects(), NumAccessors };\n }\n\n bool registerAccessor(AccessorDecl *accessor, AccessorIndex index);\n };\n\n llvm::PointerIntPair> Accessors;\n\n struct {\n unsigned IsGetterMutatingComputed : 1;\n unsigned IsGetterMutating : 1;\n unsigned IsSetterMutatingComputed : 1;\n unsigned IsSetterMutating : 1;\n unsigned OpaqueReadOwnershipComputed : 1;\n unsigned OpaqueReadOwnership : 2;\n unsigned ImplInfoComputed : 1;\n unsigned RequiresOpaqueAccessorsComputed : 1;\n unsigned RequiresOpaqueAccessors : 1;\n unsigned RequiresOpaqueModifyCoroutineComputed : 1;\n unsigned RequiresOpaqueModifyCoroutine : 1;\n } LazySemanticInfo = { };\n\n \/\/\/ The implementation info for the accessors.\n StorageImplInfo ImplInfo;\n\n \/\/\/ Add a synthesized accessor.\n void setSynthesizedAccessor(AccessorKind kind, AccessorDecl *getter);\n\nprotected:\n AbstractStorageDecl(DeclKind Kind, bool IsStatic, DeclContext *DC,\n DeclName Name, SourceLoc NameLoc,\n StorageIsMutable_t supportsMutation)\n : ValueDecl(Kind, DC, Name, NameLoc),\n ImplInfo(StorageImplInfo::getSimpleStored(supportsMutation)) {\n Bits.AbstractStorageDecl.IsStatic = IsStatic;\n }\n\npublic:\n\n \/\/\/ Should this declaration be treated as if annotated with transparent\n \/\/\/ attribute.\n bool isTransparent() const;\n\n \/\/\/ Is this a type ('static') variable?\n bool isStatic() const {\n return Bits.AbstractStorageDecl.IsStatic;\n }\n void setStatic(bool IsStatic) {\n Bits.AbstractStorageDecl.IsStatic = IsStatic;\n }\n\n \/\/\/ \\returns the way 'static'\/'class' should be spelled for this declaration.\n StaticSpellingKind getCorrectStaticSpelling() const;\n\n \/\/\/ Return the interface type of the stored value.\n Type getValueInterfaceType() const;\n\n \/\/\/ Determine how this storage is implemented.\n StorageImplInfo getImplInfo() const;\n\n \/\/\/ Overwrite the registered implementation-info. This should be\n \/\/\/ used carefully.\n void setImplInfo(StorageImplInfo implInfo) {\n LazySemanticInfo.ImplInfoComputed = 1;\n ImplInfo = implInfo;\n }\n\n ReadImplKind getReadImpl() const {\n return getImplInfo().getReadImpl();\n }\n WriteImplKind getWriteImpl() const {\n return getImplInfo().getWriteImpl();\n }\n ReadWriteImplKind getReadWriteImpl() const {\n return getImplInfo().getReadWriteImpl();\n }\n\n\n \/\/\/ Return true if this is a VarDecl that has storage associated with\n \/\/\/ it.\n bool hasStorage() const {\n return getImplInfo().hasStorage();\n }\n\n \/\/\/ Return true if this storage has the basic accessors\/capability\n \/\/\/ to be mutated. This is generally constant after the accessors are\n \/\/\/ installed by the parser\/importer\/whatever.\n \/\/\/\n \/\/\/ Note that this is different from the mutability of the declaration\n \/\/\/ in the user language: sometimes we can assign to declarations that\n \/\/\/ don't support mutation (e.g. to initialize them), and sometimes we\n \/\/\/ can't mutate things that do support mutation (e.g. because their\n \/\/\/ setter is private).\n StorageIsMutable_t supportsMutation() const {\n return getImplInfo().supportsMutation();\n }\n\n \/\/\/ isSettable - Determine whether references to this decl may appear\n \/\/\/ on the left-hand side of an assignment or as the operand of a\n \/\/\/ `&` or 'inout' operator.\n bool isSettable(const DeclContext *UseDC,\n const DeclRefExpr *base = nullptr) const;\n\n \/\/\/ Does this storage declaration have explicitly-defined accessors\n \/\/\/ written in the source?\n bool hasParsedAccessors() const;\n\n \/\/\/ Return the ownership of values opaquely read from this storage.\n OpaqueReadOwnership getOpaqueReadOwnership() const;\n void setOpaqueReadOwnership(OpaqueReadOwnership ownership) {\n LazySemanticInfo.OpaqueReadOwnership = unsigned(ownership);\n LazySemanticInfo.OpaqueReadOwnershipComputed = true;\n }\n\n \/\/\/ Return true if reading this storage requires the ability to\n \/\/\/ modify the base value.\n bool isGetterMutating() const;\n void setIsGetterMutating(bool isMutating) {\n LazySemanticInfo.IsGetterMutating = isMutating;\n LazySemanticInfo.IsGetterMutatingComputed = true;\n }\n \n \/\/\/ Return true if modifying this storage requires the ability to\n \/\/\/ modify the base value.\n bool isSetterMutating() const;\n void setIsSetterMutating(bool isMutating) {\n LazySemanticInfo.IsSetterMutating = isMutating;\n LazySemanticInfo.IsSetterMutatingComputed = true;\n }\n\n AccessorDecl *getAccessor(AccessorKind kind) const {\n if (auto info = Accessors.getPointer())\n return info->getAccessor(kind);\n return nullptr;\n }\n\n ArrayRef getAllAccessors() const {\n if (const auto *info = Accessors.getPointer())\n return info->getAllAccessors();\n return {};\n }\n\n \/\/\/ Return an accessor that this storage is expected to have, synthesizing\n \/\/\/ one if necessary. Note that will always synthesize one, even if the\n \/\/\/ accessor is not part of the expected opaque set for the storage, so use\n \/\/\/ with caution.\n AccessorDecl *getSynthesizedAccessor(AccessorKind kind) const;\n\n \/\/\/ Return an accessor part of the set of opaque accessors dictated by the\n \/\/\/ requirements of the ABI.\n \/\/\/\n \/\/\/ This will synthesize the accessor if one is required but not specified\n \/\/\/ in source; for example, most of the time a mutable property is required\n \/\/\/ to have a 'modify' accessor, but if the property was only written with\n \/\/\/ 'get' and 'set' accessors, 'modify' will be synthesized to call 'get'\n \/\/\/ followed by 'set'.\n \/\/\/\n \/\/\/ If the accessor is not needed for ABI reasons, this returns nullptr.\n \/\/\/ To ensure an accessor is always returned, use getSynthesizedAccessor().\n AccessorDecl *getOpaqueAccessor(AccessorKind kind) const;\n\n \/\/\/ Collect all opaque accessors.\n ArrayRef\n getOpaqueAccessors(llvm::SmallVectorImpl &scratch) const;\n\n \/\/\/ Return an accessor that was written in source. Returns null if the\n \/\/\/ accessor was not explicitly defined by the user.\n AccessorDecl *getParsedAccessor(AccessorKind kind) const;\n\n \/\/\/ Visit all parsed accessors.\n void visitParsedAccessors(llvm::function_ref) const;\n\n \/\/\/ Visit all opaque accessor kinds.\n void visitExpectedOpaqueAccessors(\n llvm::function_ref) const;\n\n \/\/\/ Visit all opaque accessors.\n void visitOpaqueAccessors(llvm::function_ref) const;\n\n \/\/\/ Visit all eagerly emitted accessors.\n \/\/\/\n \/\/\/ This is the union of the parsed and opaque sets.\n void visitEmittedAccessors(llvm::function_ref) const;\n\n void setAccessors(SourceLoc lbraceLoc, ArrayRef accessors,\n SourceLoc rbraceLoc);\n\n \/\/\/ Add a setter to an existing Computed var.\n \/\/\/\n \/\/\/ This should only be used by the ClangImporter.\n void setComputedSetter(AccessorDecl *Set);\n\n \/\/\/ Does this storage require opaque accessors of any kind?\n bool requiresOpaqueAccessors() const;\n\n \/\/\/ Does this storage require an opaque accessor of the given kind?\n bool requiresOpaqueAccessor(AccessorKind kind) const;\n\n \/\/\/ Does this storage require a 'get' accessor in its opaque-accessors set?\n bool requiresOpaqueGetter() const {\n return getOpaqueReadOwnership() != OpaqueReadOwnership::Borrowed;\n }\n\n \/\/\/ Does this storage require a 'read' accessor in its opaque-accessors set?\n bool requiresOpaqueReadCoroutine() const {\n return getOpaqueReadOwnership() != OpaqueReadOwnership::Owned;\n }\n\n \/\/\/ Does this storage require a 'set' accessor in its opaque-accessors set?\n bool requiresOpaqueSetter() const { return supportsMutation(); }\n\n \/\/\/ Does this storage require a 'modify' accessor in its opaque-accessors set?\n bool requiresOpaqueModifyCoroutine() const;\n\n \/\/\/ Does this storage have any explicit observers (willSet or didSet) attached\n \/\/\/ to it?\n bool hasObservers() const {\n return getParsedAccessor(AccessorKind::WillSet) ||\n getParsedAccessor(AccessorKind::DidSet);\n }\n\n SourceRange getBracesRange() const {\n if (auto info = Accessors.getPointer())\n return info->getBracesRange();\n return SourceRange();\n }\n\n AccessLevel getSetterFormalAccess() const;\n\n AccessScope\n getSetterFormalAccessScope(const DeclContext *useDC = nullptr,\n bool treatUsableFromInlineAsPublic = false) const;\n\n void setSetterAccess(AccessLevel accessLevel) {\n assert(!Accessors.getInt().hasValue());\n overwriteSetterAccess(accessLevel);\n }\n\n void overwriteSetterAccess(AccessLevel accessLevel);\n\n \/\/\/ Given that this is an Objective-C property or subscript declaration,\n \/\/\/ produce its getter selector.\n ObjCSelector\n getObjCGetterSelector(Identifier preferredName = Identifier()) const;\n\n \/\/\/ Given that this is an Objective-C property or subscript declaration,\n \/\/\/ produce its setter selector.\n ObjCSelector\n getObjCSetterSelector(Identifier preferredName = Identifier()) const;\n\n AbstractStorageDecl *getOverriddenDecl() const {\n return cast_or_null(ValueDecl::getOverriddenDecl());\n }\n\n \/\/\/ Returns the location of 'override' keyword, if any.\n SourceLoc getOverrideLoc() const;\n\n \/\/\/ Returns true if this declaration has a setter accessible from the given\n \/\/\/ context.\n \/\/\/\n \/\/\/ If \\p DC is null, returns true only if the setter is public.\n \/\/\/\n \/\/\/ See \\c isAccessibleFrom for a discussion of the \\p forConformance\n \/\/\/ parameter.\n bool isSetterAccessibleFrom(const DeclContext *DC,\n bool forConformance=false) const;\n\n \/\/\/ Determine how this storage declaration should actually be accessed.\n AccessStrategy getAccessStrategy(AccessSemantics semantics,\n AccessKind accessKind,\n ModuleDecl *module,\n ResilienceExpansion expansion) const;\n\n \/\/\/ Should this declaration behave as if it must be accessed\n \/\/\/ resiliently, even when we're building a non-resilient module?\n \/\/\/\n \/\/\/ This is used for diagnostics, because we do not want a behavior\n \/\/\/ change between builds with resilience enabled and disabled.\n bool isFormallyResilient() const;\n\n \/\/\/ Do we need to use resilient access patterns outside of this\n \/\/\/ property's resilience domain?\n bool isResilient() const;\n\n \/\/\/ Do we need to use resilient access patterns when accessing this\n \/\/\/ property from the given module?\n bool isResilient(ModuleDecl *M, ResilienceExpansion expansion) const;\n\n \/\/\/ True if the storage can be referenced by a keypath directly.\n \/\/\/ Otherwise, its override must be referenced.\n bool isValidKeyPathComponent() const;\n\n \/\/\/ True if the storage exports a property descriptor for key paths in\n \/\/\/ other modules.\n bool exportsPropertyDescriptor() const;\n\n \/\/\/ True if any of the accessors to the storage is private or fileprivate.\n bool hasPrivateAccessor() const;\n\n bool hasDidSetOrWillSetDynamicReplacement() const;\n\n bool hasAnyNativeDynamicAccessors() const;\n\n \/\/ Implement isa\/cast\/dyncast\/etc.\n static bool classof(const Decl *D) {\n return D->getKind() >= DeclKind::First_AbstractStorageDecl &&\n D->getKind() <= DeclKind::Last_AbstractStorageDecl;\n }\n};\n\n\/\/\/ Describes which synthesized property for a property with an attached\n\/\/\/ wrapper is being referenced.\nenum class PropertyWrapperSynthesizedPropertyKind {\n \/\/\/ The backing storage property, which is a stored property of the\n \/\/\/ wrapper type.\n Backing,\n \/\/\/ A storage wrapper (e.g., `$foo`), which is a wrapper over the\n \/\/\/ wrapper instance's `projectedValue` property.\n StorageWrapper,\n};\n\n\/\/\/ VarDecl - 'var' and 'let' declarations.\nclass VarDecl : public AbstractStorageDecl {\n friend class NamingPatternRequest;\n NamedPattern *NamingPattern = nullptr;\n\npublic:\n enum class Introducer : uint8_t {\n Let = 0,\n Var = 1\n };\n\nprotected:\n PointerUnion Parent;\n\n VarDecl(DeclKind kind, bool isStatic, Introducer introducer,\n bool isCaptureList, SourceLoc nameLoc, Identifier name,\n DeclContext *dc, StorageIsMutable_t supportsMutation);\n\npublic:\n VarDecl(bool isStatic, Introducer introducer, bool isCaptureList,\n SourceLoc nameLoc, Identifier name, DeclContext *dc)\n : VarDecl(DeclKind::Var, isStatic, introducer, isCaptureList, nameLoc,\n name, dc, StorageIsMutable_t(introducer == Introducer::Var)) {}\n\n SourceRange getSourceRange() const;\n\n Identifier getName() const { return getBaseIdentifier(); }\n\n \/\/\/ Returns the string for the base name, or \"_\" if this is unnamed.\n StringRef getNameStr() const {\n return hasName() ? getBaseIdentifier().str() : \"_\";\n }\n\n \/\/\/ Get the type of the variable within its context. If the context is generic,\n \/\/\/ this will use archetypes.\n Type getType() const;\n\n \/\/\/ Retrieve the source range of the variable type, or an invalid range if the\n \/\/\/ variable's type is not explicitly written in the source.\n \/\/\/\n \/\/\/ Only for use in diagnostics. It is not always possible to always\n \/\/\/ precisely point to the variable type because of type aliases.\n SourceRange getTypeSourceRangeForDiagnostics() const;\n\n \/\/\/ Returns whether the var is settable in the specified context: this\n \/\/\/ is either because it is a stored var, because it has a custom setter, or\n \/\/\/ is a let member in an initializer.\n \/\/\/\n \/\/\/ Pass a null context and null base to check if it's always settable.\n bool isSettable(const DeclContext *UseDC,\n const DeclRefExpr *base = nullptr) const;\n\n \/\/\/ Return the parent pattern binding that may provide an initializer for this\n \/\/\/ VarDecl. This returns null if there is none associated with the VarDecl.\n PatternBindingDecl *getParentPatternBinding() const {\n if (!Parent)\n return nullptr;\n return Parent.dyn_cast();\n }\n void setParentPatternBinding(PatternBindingDecl *PBD) {\n assert(PBD);\n Parent = PBD;\n }\n\n \/\/\/ Return the Pattern involved in initializing this VarDecl. However, recall\n \/\/\/ that the Pattern may be involved in initializing more than just this one\n \/\/\/ vardecl. For example, if this is a VarDecl for \"x\", the pattern may be\n \/\/\/ \"(x, y)\" and the initializer on the PatternBindingDecl may be \"(1,2)\" or\n \/\/\/ \"foo()\".\n \/\/\/\n \/\/\/ If this has no parent pattern binding decl or statement associated, it\n \/\/\/ returns null.\n \/\/\/\n Pattern *getParentPattern() const;\n\n \/\/\/ Returns the parsed type of this variable declaration. For parameters, this\n \/\/\/ is the parsed type the user explicitly wrote. For variables, this is the\n \/\/\/ type the user wrote in the typed pattern that binds this variable.\n \/\/\/\n \/\/\/ Note that there are many cases where the user may elide types. This will\n \/\/\/ return null in those cases.\n TypeRepr *getTypeReprOrParentPatternTypeRepr() const;\n\n \/\/\/ Return the statement that owns the pattern associated with this VarDecl,\n \/\/\/ if one exists.\n \/\/\/\n \/\/\/ NOTE: After parsing and before type checking, all VarDecls from\n \/\/\/ CaseLabelItem's Patterns return their CaseStmt. After type checking, we\n \/\/\/ will have constructed the CaseLabelItem VarDecl linked list implying this\n \/\/\/ will return nullptr. After type checking, if one wishes to find a parent\n \/\/\/ pattern of a VarDecl of a CaseStmt, \\see getRecursiveParentPatternStmt\n \/\/\/ instead.\n Stmt *getParentPatternStmt() const {\n if (!Parent)\n return nullptr;\n return Parent.dyn_cast();\n }\n\n void setParentPatternStmt(Stmt *s) {\n assert(s);\n Parent = s;\n }\n\n \/\/\/ Look for the parent pattern stmt of this var decl, recursively\n \/\/\/ looking through var decl pointers and then through any\n \/\/\/ fallthroughts.\n Stmt *getRecursiveParentPatternStmt() const;\n\n \/\/\/ Returns the var decl that this var decl is an implicit reference to if\n \/\/\/ such a var decl exists.\n VarDecl *getParentVarDecl() const {\n if (!Parent)\n return nullptr;\n return Parent.dyn_cast();\n }\n\n \/\/\/ Set \\p v to be the pattern produced VarDecl that is the parent of this\n \/\/\/ var decl.\n void setParentVarDecl(VarDecl *v) {\n assert(v && v != this);\n Parent = v;\n }\n\n NamedPattern *getNamingPattern() const;\n void setNamingPattern(NamedPattern *Pat);\n\n \/\/\/ If this is a VarDecl that does not belong to a CaseLabelItem's pattern,\n \/\/\/ return this. Otherwise, this VarDecl must belong to a CaseStmt's\n \/\/\/ CaseLabelItem. In that case, return the first case label item of the first\n \/\/\/ case stmt in a sequence of case stmts that fallthrough into each other.\n \/\/\/\n \/\/\/ NOTE: During type checking, we emit an error if we have a single case\n \/\/\/ label item with a pattern that has multiple var decls of the same\n \/\/\/ name. This means that during type checking and before type checking, we\n \/\/\/ may have a _malformed_ switch stmt var decl linked list since var decls in\n \/\/\/ the same case label item that have the same name will point at the same\n \/\/\/ canonical var decl, namely the first var decl with the name in the\n \/\/\/ canonical case label item's var decl list. This is ok, since we are going\n \/\/\/ to emit the error, but it requires us to be more careful\/cautious before\n \/\/\/ type checking has been complete when relying on canonical var decls\n \/\/\/ matching up.\n VarDecl *getCanonicalVarDecl() const;\n\n \/\/\/ If this is a case stmt var decl, return the var decl that corresponds to\n \/\/\/ this var decl in the first case label item of the case stmt. Returns\n \/\/\/ nullptr if this isn't a VarDecl that is part of a case stmt.\n NullablePtr getCorrespondingFirstCaseLabelItemVarDecl() const;\n\n \/\/\/ If this is a case stmt var decl, return the case body var decl that this\n \/\/\/ var decl maps to.\n NullablePtr getCorrespondingCaseBodyVariable() const;\n\n \/\/\/ Return true if this var decl is an implicit var decl belonging to a case\n \/\/\/ stmt's body.\n bool isCaseBodyVariable() const;\n\n \/\/\/ True if the global stored property requires lazy initialization.\n bool isLazilyInitializedGlobal() const;\n\n \/\/\/ Return the initializer involved in this VarDecl. Recall that the\n \/\/\/ initializer may be involved in initializing more than just this one\n \/\/\/ vardecl though. For example, if this is a VarDecl for \"x\", the pattern\n \/\/\/ may be \"(x, y)\" and the initializer on the PatternBindingDecl may be\n \/\/\/ \"(1,2)\" or \"foo()\".\n \/\/\/\n \/\/\/ If this has no parent pattern binding decl associated, or if that pattern\n \/\/\/ binding has no initial value, this returns null.\n \/\/\/\n Expr *getParentInitializer() const {\n if (auto *PBD = getParentPatternBinding()) {\n const auto i = PBD->getPatternEntryIndexForVarDecl(this);\n return PBD->getInit(i);\n }\n return nullptr;\n }\n\n \/\/\/ Whether there exists an initializer for this \\c VarDecl.\n bool isParentInitialized() const {\n if (auto *PBD = getParentPatternBinding()) {\n const auto i = PBD->getPatternEntryIndexForVarDecl(this);\n return PBD->isInitialized(i);\n }\n return false;\n }\n\n \/\/ Return whether this VarDecl has an initial value, either by checking\n \/\/ if it has an initializer in its parent pattern binding or if it has\n \/\/ the @_hasInitialValue attribute.\n bool hasInitialValue() const {\n return getAttrs().hasAttribute() ||\n isParentInitialized();\n }\n\n VarDecl *getOverriddenDecl() const {\n return cast_or_null(AbstractStorageDecl::getOverriddenDecl());\n }\n \n \/\/\/ Is this an immutable 'let' property?\n \/\/\/\n \/\/\/ If this is a ParamDecl, isLet() is true iff\n \/\/\/ getSpecifier() == Specifier::Default.\n bool isLet() const { return getIntroducer() == Introducer::Let; }\n\n Introducer getIntroducer() const {\n return Introducer(Bits.VarDecl.Introducer);\n }\n\n void setIntroducer(Introducer value) {\n Bits.VarDecl.Introducer = uint8_t(value);\n }\n\n \/\/\/ Is this an element in a capture list?\n bool isCaptureList() const { return Bits.VarDecl.IsCaptureList; }\n \n \/\/\/ Is this a capture of the self param?\n bool isSelfParamCapture() const { return Bits.VarDecl.IsSelfParamCapture; }\n void setIsSelfParamCapture(bool IsSelfParamCapture = true) {\n Bits.VarDecl.IsSelfParamCapture = IsSelfParamCapture;\n }\n\n \/\/\/ Return true if this vardecl has an initial value bound to it in a way\n \/\/\/ that isn't represented in the AST with an initializer in the pattern\n \/\/\/ binding. This happens in cases like \"for i in ...\", switch cases, etc.\n bool hasNonPatternBindingInit() const {\n return Bits.VarDecl.HasNonPatternBindingInit;\n }\n void setHasNonPatternBindingInit(bool V = true) {\n Bits.VarDecl.HasNonPatternBindingInit = V;\n }\n\n \/\/\/ Determines if this var has an initializer expression that should be\n \/\/\/ exposed to clients.\n \/\/\/ There's a very narrow case when we would: if the decl is an instance\n \/\/\/ member with an initializer expression and the parent type is\n \/\/\/ @frozen and resides in a resilient module.\n bool isInitExposedToClients() const;\n \n \/\/\/ Is this a special debugger variable?\n bool isDebuggerVar() const { return Bits.VarDecl.IsDebuggerVar; }\n void setDebuggerVar(bool IsDebuggerVar) {\n Bits.VarDecl.IsDebuggerVar = IsDebuggerVar;\n }\n\n \/\/\/ Is this the synthesized storage for a 'lazy' property?\n bool isLazyStorageProperty() const {\n return Bits.VarDecl.IsLazyStorageProperty;\n }\n void setLazyStorageProperty(bool IsLazyStorage) {\n Bits.VarDecl.IsLazyStorageProperty = IsLazyStorage;\n }\n\n \/\/\/ True if this is a top-level global variable from the main source file.\n bool isTopLevelGlobal() const { return Bits.VarDecl.IsTopLevelGlobal; }\n void setTopLevelGlobal(bool b) { Bits.VarDecl.IsTopLevelGlobal = b; }\n \n \/\/\/ Retrieve the custom attributes that attach property wrappers to this\n \/\/\/ property. The returned list contains all of the attached property wrapper\n \/\/\/ attributes in source order, which means the outermost wrapper attribute\n \/\/\/ is provided first.\n llvm::TinyPtrVector getAttachedPropertyWrappers() const;\n\n \/\/\/ Whether this property has any attached property wrappers.\n bool hasAttachedPropertyWrapper() const;\n \n \/\/\/ Whether all of the attached property wrappers have an init(wrappedValue:)\n \/\/\/ initializer.\n bool allAttachedPropertyWrappersHaveWrappedValueInit() const;\n \n \/\/\/ Retrieve the type of the attached property wrapper as a contextual\n \/\/\/ type.\n \/\/\/\n \/\/\/ \\param index Which property wrapper type is being computed, where 0\n \/\/\/ indicates the first (outermost) attached property wrapper.\n \/\/\/\n \/\/\/ \\returns a NULL type for properties without attached wrappers,\n \/\/\/ an error type when the property wrapper type itself is erroneous,\n \/\/\/ or the wrapper type itself, which may involve unbound generic\n \/\/\/ types.\n Type getAttachedPropertyWrapperType(unsigned index) const;\n\n \/\/\/ Retrieve information about the attached property wrapper type.\n \/\/\/\n \/\/\/ \\param i Which attached property wrapper type is being queried, where 0 is the outermost (first)\n \/\/\/ attached property wrapper type.\n PropertyWrapperTypeInfo getAttachedPropertyWrapperTypeInfo(unsigned i) const;\n\n \/\/\/ Retrieve the fully resolved attached property wrapper type.\n \/\/\/\n \/\/\/ This type will be the fully-resolved form of\n \/\/\/ \\c getAttachedPropertyWrapperType(0), which will not contain any\n \/\/\/ unbound generic types. It will be the type of the backing property.\n Type getPropertyWrapperBackingPropertyType() const;\n\n \/\/\/ Retrieve information about the backing properties of the attached\n \/\/\/ property wrapper.\n PropertyWrapperBackingPropertyInfo\n getPropertyWrapperBackingPropertyInfo() const;\n\n \/\/\/ Retrieve information about the mutability of the composed\n \/\/\/ property wrappers.\n Optional\n getPropertyWrapperMutability() const;\n\n \/\/\/ Returns whether this property is the backing storage property or a storage\n \/\/\/ wrapper for wrapper instance's projectedValue. If this property is\n \/\/\/ neither, then it returns `None`.\n Optional\n getPropertyWrapperSynthesizedPropertyKind() const;\n\n \/\/\/ Retrieve the backing storage property for a property that has an\n \/\/\/ attached property wrapper.\n \/\/\/\n \/\/\/ The backing storage property will be a stored property of the\n \/\/\/ wrapper's type. This will be equivalent to\n \/\/\/ \\c getAttachedPropertyWrapperType(0) when it is fully-specified;\n \/\/\/ if \\c getAttachedPropertyWrapperType(0) involves an unbound\n \/\/\/ generic type, the backing storage property will be the appropriate\n \/\/\/ bound generic version.\n VarDecl *getPropertyWrapperBackingProperty() const;\n\n \/\/\/ Retreive the storage wrapper for a property that has an attached\n \/\/\/ property wrapper.\n VarDecl *getPropertyWrapperStorageWrapper() const;\n\n \/\/\/ Retrieve the backing storage property for a lazy property.\n VarDecl *getLazyStorageProperty() const;\n\n \/\/\/ Whether the memberwise initializer parameter for a property with a\n \/\/\/ property wrapper type uses the wrapped type. This will occur, for example,\n \/\/\/ when there is an explicitly-specified initializer like:\n \/\/\/\n \/\/\/ \\code\n \/\/\/ @Lazy var i = 17\n \/\/\/ \\endcode\n \/\/\/\n \/\/\/ Or when there is no initializer but each composed property wrapper has\n \/\/\/ a suitable `init(wrappedValue:)`.\n bool isPropertyMemberwiseInitializedWithWrappedType() const;\n\n \/\/\/ Whether the innermost property wrapper's initializer's 'wrappedValue' parameter\n \/\/\/ is marked with '@autoclosure' and '@escaping'.\n bool isInnermostPropertyWrapperInitUsesEscapingAutoClosure() const;\n\n \/\/\/ Return the interface type of the value used for the 'wrappedValue:'\n \/\/\/ parameter when initializing a property wrapper.\n \/\/\/\n \/\/\/ If the property has an attached property wrapper and the 'wrappedValue:'\n \/\/\/ parameter is an autoclosure, return a function type returning the stored\n \/\/\/ value. Otherwise, return the interface type of the stored value.\n Type getPropertyWrapperInitValueInterfaceType() const;\n\n \/\/\/ If this property is the backing storage for a property with an attached\n \/\/\/ property wrapper, return the original property.\n \/\/\/\n \/\/\/ \\param kind If not \\c None, only returns the original property when\n \/\/\/ \\c this property is the specified synthesized property.\n VarDecl *getOriginalWrappedProperty(\n Optional kind = None) const;\n\n \/\/\/ Set the property that wraps to this property as it's backing\n \/\/\/ property.\n void setOriginalWrappedProperty(VarDecl *originalProperty);\n\n \/\/\/ Return the Objective-C runtime name for this property.\n Identifier getObjCPropertyName() const;\n\n \/\/\/ Retrieve the default Objective-C selector for the getter of a\n \/\/\/ property of the given name.\n static ObjCSelector getDefaultObjCGetterSelector(ASTContext &ctx,\n Identifier propertyName);\n\n \/\/\/ Retrieve the default Objective-C selector for the setter of a\n \/\/\/ property of the given name.\n static ObjCSelector getDefaultObjCSetterSelector(ASTContext &ctx,\n Identifier propertyName);\n\n \/\/\/ If this is a simple 'let' constant, emit a note with a fixit indicating\n \/\/\/ that it can be rewritten to a 'var'. This is used in situations where the\n \/\/\/ compiler detects obvious attempts to mutate a constant.\n void emitLetToVarNoteIfSimple(DeclContext *UseDC) const;\n\n \/\/\/ Returns true if the name is the self identifier and is implicit.\n bool isSelfParameter() const;\n\n \/\/\/ Determine whether this property will be part of the implicit memberwise\n \/\/\/ initializer.\n \/\/\/\n \/\/\/ \\param preferDeclaredProperties When encountering a `lazy` property\n \/\/\/ or a property that has an attached property wrapper, prefer the\n \/\/\/ actual declared property (which may or may not be considered \"stored\"\n \/\/\/ as the moment) to the backing storage property. Otherwise, the stored\n \/\/\/ backing property will be treated as the member-initialized property.\n bool isMemberwiseInitialized(bool preferDeclaredProperties) const;\n\n \/\/\/ Return the range of semantics attributes attached to this VarDecl.\n auto getSemanticsAttrs() const\n -> decltype(getAttrs().getAttributes()) {\n return getAttrs().getAttributes();\n }\n\n \/\/\/ Returns true if this VarDelc has the string \\p attrValue as a semantics\n \/\/\/ attribute.\n bool hasSemanticsAttr(StringRef attrValue) const {\n return llvm::any_of(getSemanticsAttrs(), [&](const SemanticsAttr *attr) {\n return attrValue.equals(attr->Value);\n });\n }\n\n \/\/ Implement isa\/cast\/dyncast\/etc.\n static bool classof(const Decl *D) { \n return D->getKind() == DeclKind::Var || D->getKind() == DeclKind::Param; \n }\n};\n\nenum class ParamSpecifier : uint8_t {\n Default = 0,\n InOut = 1,\n Shared = 2,\n Owned = 3,\n};\n\n\/\/\/ A function parameter declaration.\nclass ParamDecl : public VarDecl {\n friend class DefaultArgumentInitContextRequest;\n friend class DefaultArgumentExprRequest;\n\n llvm::PointerIntPair ArgumentNameAndDestructured;\n SourceLoc ParameterNameLoc;\n SourceLoc ArgumentNameLoc;\n SourceLoc SpecifierLoc;\n\n TypeRepr *TyRepr = nullptr;\n\n struct StoredDefaultArgument {\n PointerUnion DefaultArg;\n\n \/\/\/ Stores the context for the default argument as well as a bit to\n \/\/\/ indicate whether the default expression has been type-checked.\n llvm::PointerIntPair InitContextAndIsTypeChecked;\n\n StringRef StringRepresentation;\n CaptureInfo Captures;\n };\n\n \/\/\/ Retrieve the cached initializer context for the parameter's default\n \/\/\/ argument without triggering a request.\n Optional getCachedDefaultArgumentInitContext() const;\n\n enum class Flags : uint8_t {\n \/\/\/ Whether or not this parameter is vargs.\n IsVariadic = 1 << 0,\n\n \/\/\/ Whether or not this parameter is `@autoclosure`.\n IsAutoClosure = 1 << 1,\n };\n\n \/\/\/ The default value, if any, along with flags.\n llvm::PointerIntPair>\n DefaultValueAndFlags;\n\n friend class ParamSpecifierRequest;\n\npublic:\n ParamDecl(SourceLoc specifierLoc, SourceLoc argumentNameLoc,\n Identifier argumentName, SourceLoc parameterNameLoc,\n Identifier parameterName, DeclContext *dc);\n\n \/\/\/ Create a new ParamDecl identical to the first except without the interface type.\n static ParamDecl *cloneWithoutType(const ASTContext &Ctx, ParamDecl *PD);\n \n \/\/\/ Retrieve the argument (API) name for this function parameter.\n Identifier getArgumentName() const {\n return ArgumentNameAndDestructured.getPointer();\n }\n\n \/\/\/ Retrieve the parameter (local) name for this function parameter.\n Identifier getParameterName() const { return getName(); }\n\n \/\/\/ Retrieve the source location of the argument (API) name.\n \/\/\/\n \/\/\/ The resulting source location will be valid if the argument name\n \/\/\/ was specified separately from the parameter name.\n SourceLoc getArgumentNameLoc() const { return ArgumentNameLoc; }\n\n SourceLoc getParameterNameLoc() const { return ParameterNameLoc; }\n\n SourceLoc getSpecifierLoc() const { return SpecifierLoc; }\n\n \/\/\/ Retrieve the TypeRepr corresponding to the parsed type of the parameter, if it exists.\n TypeRepr *getTypeRepr() const { return TyRepr; }\n void setTypeRepr(TypeRepr *repr) { TyRepr = repr; }\n\n bool isDestructured() const { return ArgumentNameAndDestructured.getInt(); }\n void setDestructured(bool repr) { ArgumentNameAndDestructured.setInt(repr); }\n\n DefaultArgumentKind getDefaultArgumentKind() const {\n return static_cast(Bits.ParamDecl.defaultArgumentKind);\n }\n bool isDefaultArgument() const {\n return getDefaultArgumentKind() != DefaultArgumentKind::None;\n }\n void setDefaultArgumentKind(DefaultArgumentKind K) {\n Bits.ParamDecl.defaultArgumentKind = static_cast(K);\n }\n\n \/\/\/ Whether this parameter has a default argument expression available.\n \/\/\/\n \/\/\/ Note that this will return false for deserialized declarations, which only\n \/\/\/ have a textual representation of their default expression.\n bool hasDefaultExpr() const;\n\n \/\/\/ Whether this parameter has a caller-side default argument expression\n \/\/\/ such as the magic literal \\c #function.\n bool hasCallerSideDefaultExpr() const;\n\n \/\/\/ Retrieve the fully type-checked default argument expression for this\n \/\/\/ parameter, or \\c nullptr if there is no default expression.\n \/\/\/\n \/\/\/ Note that while this will produce a type-checked expression for\n \/\/\/ caller-side default arguments such as \\c #function, this is done purely to\n \/\/\/ check whether the code is valid. Such default arguments get re-created\n \/\/\/ at the call site in order to have the correct context information.\n Expr *getTypeCheckedDefaultExpr() const;\n\n \/\/\/ Retrieve the potentially un-type-checked default argument expression for\n \/\/\/ this parameter, which can be queried for information such as its source\n \/\/\/ range and textual representation. Returns \\c nullptr if there is no\n \/\/\/ default expression.\n Expr *getStructuralDefaultExpr() const {\n if (auto stored = DefaultValueAndFlags.getPointer())\n return stored->DefaultArg.dyn_cast();\n return nullptr;\n }\n\n VarDecl *getStoredProperty() const {\n if (auto stored = DefaultValueAndFlags.getPointer())\n return stored->DefaultArg.dyn_cast();\n return nullptr;\n }\n\n \/\/\/ Sets a new default argument expression for this parameter. This should\n \/\/\/ only be called internally by ParamDecl and AST walkers.\n \/\/\/\n \/\/\/ \\param E The new default argument.\n \/\/\/ \\param isTypeChecked Whether this argument should be used as the\n \/\/\/ parameter's fully type-checked default argument.\n void setDefaultExpr(Expr *E, bool isTypeChecked);\n\n void setStoredProperty(VarDecl *var);\n\n \/\/\/ Retrieve the initializer context for the parameter's default argument.\n Initializer *getDefaultArgumentInitContext() const;\n\n void setDefaultArgumentInitContext(Initializer *initContext);\n\n CaptureInfo getDefaultArgumentCaptureInfo() const {\n assert(DefaultValueAndFlags.getPointer());\n return DefaultValueAndFlags.getPointer()->Captures;\n }\n\n void setDefaultArgumentCaptureInfo(CaptureInfo captures);\n\n \/\/\/ Extracts the text of the default argument attached to the provided\n \/\/\/ ParamDecl, removing all inactive #if clauses and providing only the\n \/\/\/ text of active #if clauses.\n \/\/\/\n \/\/\/ For example, the default argument:\n \/\/\/ ```\n \/\/\/ {\n \/\/\/ #if false\n \/\/\/ print(\"false\")\n \/\/\/ #else\n \/\/\/ print(\"true\")\n \/\/\/ #endif\n \/\/\/ }\n \/\/\/ ```\n \/\/\/ will return\n \/\/\/ ```\n \/\/\/ {\n \/\/\/ print(\"true\")\n \/\/\/ }\n \/\/\/ ```\n \/\/\/ \\sa getDefaultValue\n StringRef getDefaultValueStringRepresentation(\n SmallVectorImpl &scratch) const;\n\n void setDefaultValueStringRepresentation(StringRef stringRepresentation);\n\n \/\/\/ Whether or not this parameter is varargs.\n bool isVariadic() const {\n return DefaultValueAndFlags.getInt().contains(Flags::IsVariadic);\n }\n void setVariadic(bool value = true) {\n auto flags = DefaultValueAndFlags.getInt();\n DefaultValueAndFlags.setInt(value ? flags | Flags::IsVariadic\n : flags - Flags::IsVariadic);\n }\n\n \/\/\/ Whether or not this parameter is marked with `@autoclosure`.\n bool isAutoClosure() const {\n return DefaultValueAndFlags.getInt().contains(Flags::IsAutoClosure);\n }\n void setAutoClosure(bool value = true) {\n auto flags = DefaultValueAndFlags.getInt();\n DefaultValueAndFlags.setInt(value ? flags | Flags::IsAutoClosure\n : flags - Flags::IsAutoClosure);\n }\n\n \/\/\/ Does this parameter reject temporary pointer conversions?\n bool isNonEphemeral() const {\n if (getAttrs().hasAttribute())\n return true;\n\n \/\/ Only pointer parameters can be non-ephemeral.\n auto ty = getInterfaceType();\n if (!ty->lookThroughSingleOptionalType()->getAnyPointerElementType())\n return false;\n\n \/\/ Enum element pointer parameters are always non-ephemeral.\n auto *parentDecl = getDeclContext()->getAsDecl();\n if (parentDecl && isa(parentDecl))\n return true;\n\n return false;\n }\n\n \/\/\/ Attempt to apply an implicit `@_nonEphemeral` attribute to this parameter.\n void setNonEphemeralIfPossible() {\n \/\/ Don't apply the attribute if this isn't a pointer param.\n auto type = getInterfaceType();\n if (!type->lookThroughSingleOptionalType()->getAnyPointerElementType())\n return;\n\n if (!getAttrs().hasAttribute()) {\n auto &ctx = getASTContext();\n getAttrs().add(new (ctx) NonEphemeralAttr(\/*IsImplicit*\/ true));\n }\n }\n\n \/\/\/ Remove the type of this varargs element designator, without the array\n \/\/\/ type wrapping it. A parameter like \"Int...\" will have formal parameter\n \/\/\/ type of \"[Int]\" and this returns \"Int\".\n static Type getVarargBaseTy(Type VarArgT);\n \n \/\/\/ Remove the type of this varargs element designator, without the array\n \/\/\/ type wrapping it.\n Type getVarargBaseTy() const {\n assert(isVariadic());\n return getVarargBaseTy(getInterfaceType());\n }\n\n \/\/\/ Determine whether this declaration is an anonymous closure parameter.\n bool isAnonClosureParam() const;\n\n using Specifier = ParamSpecifier;\n\n Optional getCachedSpecifier() const {\n if (Bits.ParamDecl.SpecifierComputed)\n return Specifier(Bits.ParamDecl.Specifier);\n\n return None;\n }\n\n \/\/\/ Return the raw specifier value for this parameter.\n Specifier getSpecifier() const;\n void setSpecifier(Specifier Spec);\n\n \/\/\/ Is the type of this parameter 'inout'?\n bool isInOut() const { return getSpecifier() == Specifier::InOut; }\n \/\/\/ Is this an immutable 'shared' property?\n bool isShared() const { return getSpecifier() == Specifier::Shared; }\n \/\/\/ Is this an immutable 'owned' property?\n bool isOwned() const { return getSpecifier() == Specifier::Owned; }\n\n bool isImmutable() const {\n return isImmutableSpecifier(getSpecifier());\n }\n static bool isImmutableSpecifier(Specifier sp) {\n switch (sp) {\n case Specifier::Default:\n case Specifier::Shared:\n case Specifier::Owned:\n return true;\n case Specifier::InOut:\n return false;\n }\n llvm_unreachable(\"unhandled specifier\");\n }\n\n ValueOwnership getValueOwnership() const {\n return getValueOwnershipForSpecifier(getSpecifier());\n }\n\n static ValueOwnership getValueOwnershipForSpecifier(Specifier specifier) {\n switch (specifier) {\n case Specifier::Default:\n return ValueOwnership::Default;\n case Specifier::InOut:\n return ValueOwnership::InOut;\n case Specifier::Shared:\n return ValueOwnership::Shared;\n case Specifier::Owned:\n return ValueOwnership::Owned;\n }\n llvm_unreachable(\"unhandled specifier\");\n }\n\n static Specifier\n getParameterSpecifierForValueOwnership(ValueOwnership ownership) {\n switch (ownership) {\n case ValueOwnership::Default:\n return Specifier::Default;\n case ValueOwnership::Shared:\n return Specifier::Shared;\n case ValueOwnership::InOut:\n return Specifier::InOut;\n case ValueOwnership::Owned:\n return Specifier::Owned;\n }\n llvm_unreachable(\"unhandled ownership\");\n }\n\n SourceRange getSourceRange() const;\n\n AnyFunctionType::Param toFunctionParam(Type type = Type()) const;\n\n \/\/ Implement isa\/cast\/dyncast\/etc.\n static bool classof(const Decl *D) { \n return D->getKind() == DeclKind::Param;\n }\n};\n \n\/\/\/ Describes the kind of subscripting used in Objective-C.\nenum class ObjCSubscriptKind {\n \/\/\/ Objective-C indexed subscripting, which is based on an integral\n \/\/\/ index.\n Indexed,\n \/\/\/ Objective-C keyed subscripting, which is based on an object\n \/\/\/ argument or metatype thereof.\n Keyed\n};\n\n\/\/\/ Declares a subscripting operator for a type.\n\/\/\/\n\/\/\/ A subscript declaration is defined as a get\/set pair that produces a\n\/\/\/ specific type. For example:\n\/\/\/\n\/\/\/ \\code\n\/\/\/ subscript (i : Int) -> String {\n\/\/\/ get { \/* return ith String *\/ }\n\/\/\/ set { \/* set ith string to value *\/ }\n\/\/\/ }\n\/\/\/ \\endcode\n\/\/\/\n\/\/\/ A type with a subscript declaration can be used as the base of a subscript\n\/\/\/ expression a[i], where a is of the subscriptable type and i is the type\n\/\/\/ of the index. A subscript can have multiple indices:\n\/\/\/\n\/\/\/ \\code\n\/\/\/ struct Matrix {\n\/\/\/ subscript (i : Int, j : Int) -> Double {\n\/\/\/ get { \/* return element at position (i, j) *\/ }\n\/\/\/ set { \/* set element at position (i, j) *\/ }\n\/\/\/ }\n\/\/\/ }\n\/\/\/ \\endcode\n\/\/\/\n\/\/\/ A given type can have multiple subscript declarations, so long as the\n\/\/\/ signatures (indices and element type) are distinct.\n\/\/\/\nclass SubscriptDecl : public GenericContext, public AbstractStorageDecl {\n SourceLoc StaticLoc;\n SourceLoc ArrowLoc;\n SourceLoc EndLoc;\n ParameterList *Indices;\n TypeLoc ElementTy;\n\npublic:\n SubscriptDecl(DeclName Name,\n SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,\n SourceLoc SubscriptLoc, ParameterList *Indices,\n SourceLoc ArrowLoc, TypeLoc ElementTy, DeclContext *Parent,\n GenericParamList *GenericParams)\n : GenericContext(DeclContextKind::SubscriptDecl, Parent, GenericParams),\n AbstractStorageDecl(DeclKind::Subscript,\n StaticSpelling != StaticSpellingKind::None,\n Parent, Name, SubscriptLoc,\n \/*will be overwritten*\/ StorageIsNotMutable),\n StaticLoc(StaticLoc), ArrowLoc(ArrowLoc),\n Indices(nullptr), ElementTy(ElementTy) {\n Bits.SubscriptDecl.StaticSpelling = static_cast(StaticSpelling);\n setIndices(Indices);\n }\n \n \/\/\/ \\returns the way 'static'\/'class' was spelled in the source.\n StaticSpellingKind getStaticSpelling() const {\n return static_cast(Bits.SubscriptDecl.StaticSpelling);\n }\n \n SourceLoc getStaticLoc() const { return StaticLoc; }\n SourceLoc getSubscriptLoc() const { return getNameLoc(); }\n \n SourceLoc getStartLoc() const {\n return getStaticLoc().isValid() ? getStaticLoc() : getSubscriptLoc();\n }\n SourceLoc getEndLoc() const { return EndLoc; }\n\n void setEndLoc(SourceLoc sl) { EndLoc = sl; }\n SourceRange getSourceRange() const;\n SourceRange getSignatureSourceRange() const;\n\n \/\/\/ Retrieve the indices for this subscript operation.\n ParameterList *getIndices() { return Indices; }\n const ParameterList *getIndices() const { return Indices; }\n void setIndices(ParameterList *p);\n\n \/\/\/ Retrieve the type of the element referenced by a subscript\n \/\/\/ operation.\n Type getElementInterfaceType() const;\n TypeLoc &getElementTypeLoc() { return ElementTy; }\n const TypeLoc &getElementTypeLoc() const { return ElementTy; }\n\n \/\/\/ Determine the kind of Objective-C subscripting this declaration\n \/\/\/ implies.\n ObjCSubscriptKind getObjCSubscriptKind() const;\n\n SubscriptDecl *getOverriddenDecl() const {\n return cast_or_null(\n AbstractStorageDecl::getOverriddenDecl());\n }\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::Subscript;\n }\n \n static bool classof(const DeclContext *DC) {\n if (auto D = DC->getAsDecl())\n return classof(D);\n return false;\n }\n\n using DeclContext::operator new;\n using Decl::getASTContext;\n};\n\n\/\/\/ Encodes imported-as-member status for C functions that get imported\n\/\/\/ as methods.\nclass ImportAsMemberStatus {\n friend class AbstractFunctionDecl;\n\n \/\/ non-0 denotes import-as-member. 1 denotes no self index. n+2 denotes self\n \/\/ index of n\n uint8_t rawValue;\n\npublic:\n ImportAsMemberStatus(uint8_t rawValue = 0) : rawValue(rawValue) {}\n\n uint8_t getRawValue() const { return rawValue; }\n\n bool isImportAsMember() const { return rawValue != 0; }\n bool isInstance() const { return rawValue >= 2; }\n bool isStatic() const { return rawValue == 1; }\n uint8_t getSelfIndex() const {\n assert(isInstance() && \"not set\");\n return rawValue - 2;\n }\n void setStatic() {\n assert(!isStatic() && \"already set\");\n rawValue = 1;\n }\n void setSelfIndex(uint8_t idx) {\n assert(!isImportAsMember() && \"already set\");\n assert(idx <= UINT8_MAX-2 && \"out of bounds\");\n rawValue = idx + 2;\n }\n};\n\n\/\/\/ Base class for function-like declarations.\nclass AbstractFunctionDecl : public GenericContext, public ValueDecl {\n friend class NeedsNewVTableEntryRequest;\n\npublic:\n enum class BodyKind {\n \/\/\/ The function did not have a body in the source code file.\n None,\n\n \/\/\/ Function body is delayed, to be parsed later.\n Unparsed,\n\n \/\/\/ Function body is parsed and available as an AST subtree.\n Parsed,\n\n \/\/\/ Function body is not available, although it was written in the source.\n Skipped,\n\n \/\/\/ Function body will be synthesized on demand.\n Synthesize,\n\n \/\/\/ Function body is present and type-checked.\n TypeChecked,\n\n \/\/\/ This is a memberwise initializer that will be synthesized by SILGen.\n MemberwiseInitializer,\n\n \/\/\/ Function body text was deserialized from a .swiftmodule.\n Deserialized\n\n \/\/ This enum currently needs to fit in a 3-bit bitfield.\n };\n\n BodyKind getBodyKind() const {\n return BodyKind(Bits.AbstractFunctionDecl.BodyKind);\n }\n\n struct BodySynthesizer {\n std::pair (* Fn)(AbstractFunctionDecl *, void *);\n void *Context;\n };\n\nprivate:\n ParameterList *Params;\n\nprivate:\n \/\/\/ The generation at which we last loaded derivative function configurations.\n unsigned DerivativeFunctionConfigGeneration = 0;\n \/\/\/ Prepare to traverse the list of derivative function configurations.\n void prepareDerivativeFunctionConfigurations();\n\n \/\/\/ A uniqued list of derivative function configurations.\n \/\/\/ - `@differentiable` and `@derivative` attribute type-checking is\n \/\/\/ responsible for populating derivative function configurations specified\n \/\/\/ in the current module.\n \/\/\/ - Module loading is responsible for populating derivative function\n \/\/\/ configurations from imported modules.\n struct DerivativeFunctionConfigurationList;\n DerivativeFunctionConfigurationList *DerivativeFunctionConfigs = nullptr;\n\npublic:\n \/\/\/ Get all derivative function configurations.\n ArrayRef getDerivativeFunctionConfigurations();\n\n \/\/\/ Add the given derivative function configuration.\n void addDerivativeFunctionConfiguration(AutoDiffConfig config);\n\nprotected:\n \/\/ If a function has a body at all, we have either a parsed body AST node or\n \/\/ we have saved the end location of the unparsed body.\n union {\n \/\/\/ This enum member is active if getBodyKind() is BodyKind::Parsed or\n \/\/\/ BodyKind::TypeChecked.\n BraceStmt *Body;\n\n \/\/\/ This enum member is active if getBodyKind() is BodyKind::Deserialized.\n StringRef BodyStringRepresentation;\n\n \/\/\/ This enum member is active if getBodyKind() == BodyKind::Synthesize.\n BodySynthesizer Synthesizer;\n\n \/\/\/ The location of the function body when the body is delayed or skipped.\n \/\/\/\n \/\/\/ This enum member is active if getBodyKind() is BodyKind::Unparsed or\n \/\/\/ BodyKind::Skipped.\n SourceRange BodyRange;\n };\n\n friend class ParseAbstractFunctionBodyRequest;\n\n CaptureInfo Captures;\n\n \/\/\/ Location of the 'throws' token.\n SourceLoc ThrowsLoc;\n\n struct {\n unsigned NeedsNewVTableEntryComputed : 1;\n unsigned NeedsNewVTableEntry : 1;\n } LazySemanticInfo = { };\n\n AbstractFunctionDecl(DeclKind Kind, DeclContext *Parent, DeclName Name,\n SourceLoc NameLoc, bool Throws, SourceLoc ThrowsLoc,\n bool HasImplicitSelfDecl,\n GenericParamList *GenericParams)\n : GenericContext(DeclContextKind::AbstractFunctionDecl, Parent, GenericParams),\n ValueDecl(Kind, Parent, Name, NameLoc),\n Body(nullptr), ThrowsLoc(ThrowsLoc) {\n setBodyKind(BodyKind::None);\n Bits.AbstractFunctionDecl.HasImplicitSelfDecl = HasImplicitSelfDecl;\n Bits.AbstractFunctionDecl.Overridden = false;\n Bits.AbstractFunctionDecl.Throws = Throws;\n Bits.AbstractFunctionDecl.Synthesized = false;\n Bits.AbstractFunctionDecl.HasSingleExpressionBody = false;\n }\n\n void setBodyKind(BodyKind K) {\n Bits.AbstractFunctionDecl.BodyKind = unsigned(K);\n }\n\npublic:\n void setHasSingleExpressionBody(bool Has = true) { \n Bits.AbstractFunctionDecl.HasSingleExpressionBody = Has;\n }\n\n bool hasSingleExpressionBody() const {\n return Bits.AbstractFunctionDecl.HasSingleExpressionBody;\n }\n\n Expr *getSingleExpressionBody() const;\n void setSingleExpressionBody(Expr *NewBody);\n\n \/\/\/ Returns the string for the base name, or \"_\" if this is unnamed.\n StringRef getNameStr() const {\n assert(!getName().isSpecial() && \"Cannot get string for special names\");\n return hasName() ? getBaseIdentifier().str() : \"_\";\n }\n\n \/\/\/ Should this declaration be treated as if annotated with transparent\n \/\/\/ attribute.\n bool isTransparent() const;\n\n \/\/ Expose our import as member status\n ImportAsMemberStatus getImportAsMemberStatus() const {\n return ImportAsMemberStatus(Bits.AbstractFunctionDecl.IAMStatus);\n }\n bool isImportAsMember() const {\n return getImportAsMemberStatus().isImportAsMember();\n }\n bool isImportAsInstanceMember() const {\n return getImportAsMemberStatus().isInstance();\n }\n bool isImportAsStaticMember() const {\n return getImportAsMemberStatus().isStatic();\n }\n uint8_t getSelfIndex() const {\n return getImportAsMemberStatus().getSelfIndex();\n }\n\n void setImportAsStaticMember() {\n auto newValue = getImportAsMemberStatus();\n newValue.setStatic();\n Bits.AbstractFunctionDecl.IAMStatus = newValue.getRawValue();\n }\n void setSelfIndex(uint8_t idx) {\n auto newValue = getImportAsMemberStatus();\n newValue.setSelfIndex(idx);\n Bits.AbstractFunctionDecl.IAMStatus = newValue.getRawValue();\n }\n\n \/\/\/ Retrieve the location of the 'throws' keyword, if present.\n SourceLoc getThrowsLoc() const { return ThrowsLoc; }\n\n \/\/\/ Returns true if the function body throws.\n bool hasThrows() const { return Bits.AbstractFunctionDecl.Throws; }\n\n \/\/ FIXME: Hack that provides names with keyword arguments for accessors.\n DeclName getEffectiveFullName() const;\n\n \/\/\/ Returns true if the function has a body written in the source file.\n \/\/\/\n \/\/\/ Note that a true return value does not imply that the body was actually\n \/\/\/ parsed.\n bool hasBody() const {\n return getBodyKind() != BodyKind::None &&\n getBodyKind() != BodyKind::Skipped;\n }\n\n \/\/\/ Returns true if the text of this function's body can be retrieved either\n \/\/\/ by extracting the text from the source buffer or reading the inlinable\n \/\/\/ body from a deserialized swiftmodule.\n bool hasInlinableBodyText() const;\n\n \/\/\/ Returns the function body, if it was parsed, or nullptr otherwise.\n \/\/\/\n \/\/\/ Note that a null return value does not imply that the source code did not\n \/\/\/ have a body for this function.\n \/\/\/\n \/\/\/ \\sa hasBody()\n BraceStmt *getBody(bool canSynthesize = true) const;\n\n void setBody(BraceStmt *S, BodyKind NewBodyKind = BodyKind::Parsed);\n\n \/\/\/ Note that the body was skipped for this function. Function body\n \/\/\/ cannot be attached after this call.\n void setBodySkipped(SourceRange bodyRange) {\n \/\/ FIXME: Remove 'Parsed' from this once we can delay parsing function\n \/\/ bodies. Right now -experimental-skip-non-inlinable-function-bodies\n \/\/ requires being able to change the state from Parsed to Skipped,\n \/\/ because we're still eagerly parsing function bodies.\n assert(getBodyKind() == BodyKind::None ||\n getBodyKind() == BodyKind::Unparsed ||\n getBodyKind() == BodyKind::Parsed);\n assert(bodyRange.isValid());\n BodyRange = bodyRange;\n setBodyKind(BodyKind::Skipped);\n }\n\n \/\/\/ Note that parsing for the body was delayed.\n void setBodyDelayed(SourceRange bodyRange) {\n assert(getBodyKind() == BodyKind::None ||\n getBodyKind() == BodyKind::Skipped);\n assert(bodyRange.isValid());\n BodyRange = bodyRange;\n setBodyKind(BodyKind::Unparsed);\n }\n\n \/\/\/ Provide the parsed body for the function.\n void setBodyParsed(BraceStmt *S) {\n setBody(S, BodyKind::Parsed);\n }\n\n \/\/\/ Note that parsing for the body was delayed.\n \/\/\/\n \/\/\/ The function should return the body statement and a flag indicating\n \/\/\/ whether that body is already type-checked.\n void setBodySynthesizer(\n std::pair (* fn)(AbstractFunctionDecl *, void *),\n void *context = nullptr) {\n assert(getBodyKind() == BodyKind::None);\n Synthesizer = {fn, context};\n setBodyKind(BodyKind::Synthesize);\n }\n\n \/\/\/ Note that this is a memberwise initializer and thus the body will be\n \/\/\/ generated by SILGen.\n void setIsMemberwiseInitializer() {\n assert(getBodyKind() == BodyKind::None);\n assert(isa(this));\n setBodyKind(BodyKind::MemberwiseInitializer);\n }\n\n \/\/\/ Gets the body of this function, stripping the unused portions of #if\n \/\/\/ configs inside the body. If this function was not deserialized from a\n \/\/\/ .swiftmodule, this body is reconstructed from the original\n \/\/\/ source buffer.\n StringRef getInlinableBodyText(SmallVectorImpl &scratch) const;\n\n void setBodyStringRepresentation(StringRef body) {\n assert(getBodyKind() == BodyKind::None);\n setBodyKind(BodyKind::Deserialized);\n BodyStringRepresentation = body;\n }\n\n bool isBodyTypeChecked() const {\n return getBodyKind() == BodyKind::TypeChecked;\n }\n\n bool isBodySkipped() const {\n return getBodyKind() == BodyKind::Skipped;\n }\n\n bool isMemberwiseInitializer() const {\n return getBodyKind() == BodyKind::MemberwiseInitializer;\n }\n\n \/\/\/ For a method of a class, checks whether it will require a new entry in the\n \/\/\/ vtable.\n bool needsNewVTableEntry() const;\n\n bool isSynthesized() const {\n return Bits.AbstractFunctionDecl.Synthesized;\n }\n\n void setSynthesized(bool value = true) {\n Bits.AbstractFunctionDecl.Synthesized = value;\n }\n\npublic:\n \/\/\/ Retrieve the source range of the function body.\n SourceRange getBodySourceRange() const;\n\n \/\/\/ Retrieve the source range of the function declaration name + patterns.\n SourceRange getSignatureSourceRange() const;\n\n CaptureInfo getCaptureInfo() const { return Captures; }\n void setCaptureInfo(CaptureInfo captures) { Captures = captures; }\n\n \/\/\/ Retrieve the Objective-C selector that names this method.\n ObjCSelector getObjCSelector(DeclName preferredName = DeclName(),\n bool skipIsObjCResolution = false) const;\n\n \/\/\/ Determine whether the given method would produce an Objective-C\n \/\/\/ instance method.\n bool isObjCInstanceMethod() const;\n\n \/\/\/ Determine whether the name of an argument is an API name by default\n \/\/\/ depending on the function context.\n bool argumentNameIsAPIByDefault() const;\n\n \/\/\/ Retrieve the function's parameter list, not including 'self' if present.\n ParameterList *getParameters() {\n return Params;\n }\n const ParameterList *getParameters() const {\n return Params;\n }\n\n void setParameters(ParameterList *Params);\n\n bool hasImplicitSelfDecl() const {\n return Bits.AbstractFunctionDecl.HasImplicitSelfDecl;\n }\n\n ParamDecl **getImplicitSelfDeclStorage();\n\n \/\/\/ Retrieve the implicit 'self' parameter for methods. Returns nullptr for\n \/\/\/ free functions.\n const ParamDecl *getImplicitSelfDecl(bool createIfNeeded=true) const {\n return const_cast(this)\n ->getImplicitSelfDecl(createIfNeeded);\n }\n ParamDecl *getImplicitSelfDecl(bool createIfNeeded=true);\n\n \/\/\/ Retrieve the declaration that this method overrides, if any.\n AbstractFunctionDecl *getOverriddenDecl() const {\n return cast_or_null(ValueDecl::getOverriddenDecl());\n }\n\n \/\/\/ Whether the declaration is later overridden in the module\n \/\/\/\n \/\/\/ Overrides are resolved during type checking; only query this field after\n \/\/\/ the whole module has been checked\n bool isOverridden() const { return Bits.AbstractFunctionDecl.Overridden; }\n\n \/\/\/ The declaration has been overridden in the module\n \/\/\/\n \/\/\/ Resolved during type checking\n void setIsOverridden() { Bits.AbstractFunctionDecl.Overridden = true; }\n\n \/\/\/ Set information about the foreign error convention used by this\n \/\/\/ declaration.\n void setForeignErrorConvention(const ForeignErrorConvention &convention);\n\n \/\/\/ Get information about the foreign error convention used by this\n \/\/\/ declaration, given that it is @objc and 'throws'.\n Optional getForeignErrorConvention() const;\n\n \/\/\/ If this is a foreign C function imported as a method, get the index of\n \/\/\/ the foreign parameter imported as `self`. If the function is imported\n \/\/\/ as a static method, `-1` is returned to represent the `self` parameter\n \/\/\/ being dropped altogether. `None` is returned for a normal function\n \/\/\/ or method.\n Optional getForeignFunctionAsMethodSelfParameterIndex() const;\n \n static bool classof(const Decl *D) {\n return D->getKind() >= DeclKind::First_AbstractFunctionDecl &&\n D->getKind() <= DeclKind::Last_AbstractFunctionDecl;\n }\n\n static bool classof(const DeclContext *DC) {\n if (auto D = DC->getAsDecl())\n return classof(D);\n return false;\n }\n \n \/\/\/ True if the declaration is forced to be statically dispatched.\n bool hasForcedStaticDispatch() const;\n\n \/\/\/ Get the type of this declaration without the Self clause.\n \/\/\/ Asserts if not in type context.\n Type getMethodInterfaceType() const;\n\n \/\/\/ Tests if this is a function returning a DynamicSelfType, or a\n \/\/\/ constructor.\n bool hasDynamicSelfResult() const;\n\n using DeclContext::operator new;\n using Decl::getASTContext;\n};\n\nclass OperatorDecl;\n\nenum class SelfAccessKind : uint8_t {\n NonMutating,\n Mutating,\n Consuming,\n};\n\n\/\/\/ Diagnostic printing of \\c SelfAccessKind.\nllvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SelfAccessKind SAK);\n \n\/\/\/ FuncDecl - 'func' declaration.\nclass FuncDecl : public AbstractFunctionDecl {\n friend class AbstractFunctionDecl;\n friend class SelfAccessKindRequest;\n friend class IsStaticRequest;\n\n SourceLoc StaticLoc; \/\/ Location of the 'static' token or invalid.\n SourceLoc FuncLoc; \/\/ Location of the 'func' token.\n\n TypeLoc FnRetType;\n\nprotected:\n FuncDecl(DeclKind Kind,\n SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,\n SourceLoc FuncLoc,\n DeclName Name, SourceLoc NameLoc,\n bool Throws, SourceLoc ThrowsLoc,\n bool HasImplicitSelfDecl,\n GenericParamList *GenericParams, DeclContext *Parent)\n : AbstractFunctionDecl(Kind, Parent,\n Name, NameLoc,\n Throws, ThrowsLoc,\n HasImplicitSelfDecl, GenericParams),\n StaticLoc(StaticLoc), FuncLoc(FuncLoc) {\n assert(!Name.getBaseName().isSpecial());\n\n Bits.FuncDecl.StaticSpelling = static_cast(StaticSpelling);\n\n Bits.FuncDecl.ForcedStaticDispatch = false;\n Bits.FuncDecl.SelfAccess =\n static_cast(SelfAccessKind::NonMutating);\n Bits.FuncDecl.SelfAccessComputed = false;\n Bits.FuncDecl.IsStaticComputed = false;\n Bits.FuncDecl.IsStatic = false;\n Bits.FuncDecl.HasTopLevelLocalContextCaptures = false;\n }\n\nprivate:\n static FuncDecl *createImpl(ASTContext &Context, SourceLoc StaticLoc,\n StaticSpellingKind StaticSpelling,\n SourceLoc FuncLoc,\n DeclName Name, SourceLoc NameLoc,\n bool Throws, SourceLoc ThrowsLoc,\n GenericParamList *GenericParams,\n DeclContext *Parent,\n ClangNode ClangN);\n\n Optional getCachedSelfAccessKind() const {\n if (Bits.FuncDecl.SelfAccessComputed)\n return static_cast(Bits.FuncDecl.SelfAccess);\n\n return None;\n }\n\n Optional getCachedIsStatic() const {\n if (Bits.FuncDecl.IsStaticComputed)\n return Bits.FuncDecl.IsStatic;\n\n return None;\n }\n\npublic:\n \/\/\/ Factory function only for use by deserialization.\n static FuncDecl *createDeserialized(ASTContext &Context, SourceLoc StaticLoc,\n StaticSpellingKind StaticSpelling,\n SourceLoc FuncLoc,\n DeclName Name, SourceLoc NameLoc,\n bool Throws, SourceLoc ThrowsLoc,\n GenericParamList *GenericParams,\n DeclContext *Parent);\n\n static FuncDecl *create(ASTContext &Context, SourceLoc StaticLoc,\n StaticSpellingKind StaticSpelling,\n SourceLoc FuncLoc,\n DeclName Name, SourceLoc NameLoc,\n bool Throws, SourceLoc ThrowsLoc,\n GenericParamList *GenericParams,\n ParameterList *ParameterList,\n TypeLoc FnRetType, DeclContext *Parent,\n ClangNode ClangN = ClangNode());\n\n bool isStatic() const;\n\n \/\/\/ \\returns the way 'static'\/'class' was spelled in the source.\n StaticSpellingKind getStaticSpelling() const {\n return static_cast(Bits.FuncDecl.StaticSpelling);\n }\n \/\/\/ \\returns the way 'static'\/'class' should be spelled for this declaration.\n StaticSpellingKind getCorrectStaticSpelling() const;\n void setStatic(bool IsStatic = true) {\n Bits.FuncDecl.IsStaticComputed = true;\n Bits.FuncDecl.IsStatic = IsStatic;\n }\n\n bool isMutating() const {\n return getSelfAccessKind() == SelfAccessKind::Mutating;\n }\n bool isNonMutating() const {\n return getSelfAccessKind() == SelfAccessKind::NonMutating;\n }\n bool isConsuming() const {\n return getSelfAccessKind() == SelfAccessKind::Consuming;\n }\n bool isCallAsFunctionMethod() const;\n\n bool isMainTypeMainMethod() const;\n\n SelfAccessKind getSelfAccessKind() const;\n\n void setSelfAccessKind(SelfAccessKind mod) {\n Bits.FuncDecl.SelfAccess = static_cast(mod);\n Bits.FuncDecl.SelfAccessComputed = true;\n }\n\n SourceLoc getStaticLoc() const { return StaticLoc; }\n SourceLoc getFuncLoc() const { return FuncLoc; }\n\n SourceLoc getStartLoc() const {\n return StaticLoc.isValid() && !isa(this)\n ? StaticLoc : FuncLoc;\n }\n SourceRange getSourceRange() const;\n\n TypeLoc &getBodyResultTypeLoc() { return FnRetType; }\n const TypeLoc &getBodyResultTypeLoc() const { return FnRetType; }\n\n \/\/\/ Retrieve the result interface type of this function.\n Type getResultInterfaceType() const;\n\n \/\/\/ isUnaryOperator - Determine whether this is a unary operator\n \/\/\/ implementation. This check is a syntactic rather than type-based check,\n \/\/\/ which looks at the number of parameters specified, in order to allow\n \/\/\/ for the definition of unary operators on tuples, as in:\n \/\/\/\n \/\/\/ prefix func + (param : (a:Int, b:Int))\n \/\/\/\n \/\/\/ This also allows the unary-operator-ness of a func decl to be determined\n \/\/\/ prior to type checking.\n bool isUnaryOperator() const;\n \n \/\/\/ isBinaryOperator - Determine whether this is a binary operator\n \/\/\/ implementation. This check is a syntactic rather than type-based check,\n \/\/\/ which looks at the number of parameters specified, in order to allow\n \/\/\/ distinguishing a binary operator from a unary operator on tuples, as in:\n \/\/\/\n \/\/\/ prefix func + (_:(a:Int, b:Int)) \/\/ unary operator +(1,2)\n \/\/\/ infix func + (a:Int, b:Int) \/\/ binary operator 1 + 2\n \/\/\/\n \/\/\/ This also allows the binary-operator-ness of a func decl to be determined\n \/\/\/ prior to type checking.\n bool isBinaryOperator() const;\n\n void getLocalCaptures(SmallVectorImpl &Result) const {\n return getCaptureInfo().getLocalCaptures(Result);\n }\n\n ParamDecl **getImplicitSelfDeclStorage();\n\n \/\/\/ Get the supertype method this method overrides, if any.\n FuncDecl *getOverriddenDecl() const {\n return cast_or_null(AbstractFunctionDecl::getOverriddenDecl());\n }\n\n OperatorDecl *getOperatorDecl() const;\n\n \/\/\/ Returns true if the function is forced to be statically dispatched.\n bool hasForcedStaticDispatch() const {\n return Bits.FuncDecl.ForcedStaticDispatch;\n }\n void setForcedStaticDispatch(bool flag) {\n Bits.FuncDecl.ForcedStaticDispatch = flag;\n }\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::Func ||\n D->getKind() == DeclKind::Accessor;\n }\n static bool classof(const AbstractFunctionDecl *D) {\n return classof(static_cast(D));\n }\n static bool classof(const DeclContext *DC) {\n if (auto D = DC->getAsDecl())\n return classof(D);\n return false;\n }\n\n \/\/\/ True if the function is a defer body.\n bool isDeferBody() const;\n\n \/\/\/ Perform basic checking to determine whether the @IBAction or\n \/\/\/ @IBSegueAction attribute can be applied to this function.\n bool isPotentialIBActionTarget() const;\n\n bool hasTopLevelLocalContextCaptures() const {\n return Bits.FuncDecl.HasTopLevelLocalContextCaptures;\n }\n\n void setHasTopLevelLocalContextCaptures(bool hasCaptures=true);\n};\n\n\/\/\/ This represents an accessor function, such as a getter or setter.\nclass AccessorDecl final : public FuncDecl {\n \/\/\/ Location of the accessor keyword, e.g. 'set'.\n SourceLoc AccessorKeywordLoc;\n\n AbstractStorageDecl *Storage;\n\n AccessorDecl(SourceLoc declLoc, SourceLoc accessorKeywordLoc,\n AccessorKind accessorKind, AbstractStorageDecl *storage,\n SourceLoc staticLoc, StaticSpellingKind staticSpelling,\n bool throws, SourceLoc throwsLoc,\n bool hasImplicitSelfDecl, GenericParamList *genericParams,\n DeclContext *parent)\n : FuncDecl(DeclKind::Accessor,\n staticLoc, staticSpelling, \/*func loc*\/ declLoc,\n \/*name*\/ Identifier(), \/*name loc*\/ declLoc,\n throws, throwsLoc, hasImplicitSelfDecl, genericParams, parent),\n AccessorKeywordLoc(accessorKeywordLoc),\n Storage(storage) {\n Bits.AccessorDecl.AccessorKind = unsigned(accessorKind);\n }\n\n static AccessorDecl *createImpl(ASTContext &ctx,\n SourceLoc declLoc,\n SourceLoc accessorKeywordLoc,\n AccessorKind accessorKind,\n AbstractStorageDecl *storage,\n SourceLoc staticLoc,\n StaticSpellingKind staticSpelling,\n bool throws, SourceLoc throwsLoc,\n GenericParamList *genericParams,\n DeclContext *parent,\n ClangNode clangNode);\n\n Optional getCachedIsTransparent() const {\n if (Bits.AccessorDecl.IsTransparentComputed)\n return Bits.AccessorDecl.IsTransparent;\n return None;\n }\n\n friend class IsAccessorTransparentRequest;\n\npublic:\n static AccessorDecl *createDeserialized(ASTContext &ctx,\n SourceLoc declLoc,\n SourceLoc accessorKeywordLoc,\n AccessorKind accessorKind,\n AbstractStorageDecl *storage,\n SourceLoc staticLoc,\n StaticSpellingKind staticSpelling,\n bool throws, SourceLoc throwsLoc,\n GenericParamList *genericParams,\n DeclContext *parent);\n\n static AccessorDecl *create(ASTContext &ctx, SourceLoc declLoc,\n SourceLoc accessorKeywordLoc,\n AccessorKind accessorKind,\n AbstractStorageDecl *storage,\n SourceLoc staticLoc,\n StaticSpellingKind staticSpelling,\n bool throws, SourceLoc throwsLoc,\n GenericParamList *genericParams,\n ParameterList *parameterList,\n TypeLoc fnRetType, DeclContext *parent,\n ClangNode clangNode = ClangNode());\n\n SourceLoc getAccessorKeywordLoc() const { return AccessorKeywordLoc; }\n\n AbstractStorageDecl *getStorage() const {\n return Storage;\n }\n\n AccessorKind getAccessorKind() const {\n return AccessorKind(Bits.AccessorDecl.AccessorKind);\n }\n\n bool isGetter() const { return getAccessorKind() == AccessorKind::Get; }\n bool isSetter() const { return getAccessorKind() == AccessorKind::Set; }\n bool isAnyAddressor() const {\n auto kind = getAccessorKind();\n return kind == AccessorKind::Address\n || kind == AccessorKind::MutableAddress;\n }\n\n \/\/\/ isGetterOrSetter - Determine whether this is specifically a getter or\n \/\/\/ a setter, as opposed to some other kind of accessor.\n \/\/\/\n \/\/\/ For example, only getters and setters can be exposed to Objective-C.\n bool isGetterOrSetter() const { return isGetter() || isSetter(); }\n\n bool isObservingAccessor() const {\n switch (getAccessorKind()) {\n#define OBSERVING_ACCESSOR(ID, KEYWORD) \\\n case AccessorKind::ID: return true;\n#define ACCESSOR(ID) \\\n case AccessorKind::ID: return false;\n#include \"swift\/AST\/AccessorKinds.def\"\n }\n llvm_unreachable(\"bad accessor kind\");\n }\n\n \/\/\/ \\returns true if this is non-mutating due to applying a 'mutating'\n \/\/\/ attribute. For example a \"mutating set\" accessor.\n bool isExplicitNonMutating() const;\n\n \/\/\/ Is the accesor one of the kinds that's assumed nonmutating by default?\n bool isAssumedNonMutating() const;\n\n \/\/\/ Is this accessor one of the kinds that's implicitly a coroutine?\n bool isCoroutine() const {\n switch (getAccessorKind()) {\n#define COROUTINE_ACCESSOR(ID, KEYWORD) \\\n case AccessorKind::ID: return true;\n#define ACCESSOR(ID) \\\n case AccessorKind::ID: return false;\n#include \"swift\/AST\/AccessorKinds.def\"\n }\n llvm_unreachable(\"bad accessor kind\");\n }\n\n bool isImplicitGetter() const {\n return isGetter() && getAccessorKeywordLoc().isInvalid();\n }\n\n \/\/\/ Is this accessor a \"simple\" didSet? A \"simple\" didSet does not\n \/\/\/ use the implicit oldValue parameter in its body or does not have\n \/\/\/ an explicit parameter in its parameter list.\n bool isSimpleDidSet() const;\n\n void setIsTransparent(bool transparent) {\n Bits.AccessorDecl.IsTransparent = transparent;\n Bits.AccessorDecl.IsTransparentComputed = 1;\n }\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::Accessor;\n }\n static bool classof(const AbstractFunctionDecl *D) {\n return classof(static_cast(D));\n }\n static bool classof(const DeclContext *DC) {\n if (auto D = DC->getAsDecl())\n return classof(D);\n return false;\n }\n};\n\ninline AccessorDecl *\nAbstractStorageDecl::AccessorRecord::getAccessor(AccessorKind kind) const {\n if (auto optIndex = AccessorIndices[unsigned(kind)]) {\n auto accessor = getAllAccessors()[optIndex - 1];\n assert(accessor && accessor->getAccessorKind() == kind);\n return accessor;\n }\n return nullptr;\n}\n \n\/\/\/ This represents a 'case' declaration in an 'enum', which may declare\n\/\/\/ one or more individual comma-separated EnumElementDecls.\nclass EnumCaseDecl final : public Decl,\n private llvm::TrailingObjects {\n friend TrailingObjects;\n friend class Decl;\n SourceLoc CaseLoc;\n \n EnumCaseDecl(SourceLoc CaseLoc,\n ArrayRef Elements,\n DeclContext *DC)\n : Decl(DeclKind::EnumCase, DC),\n CaseLoc(CaseLoc)\n {\n Bits.EnumCaseDecl.NumElements = Elements.size();\n std::uninitialized_copy(Elements.begin(), Elements.end(),\n getTrailingObjects());\n }\n SourceLoc getLocFromSource() const { return CaseLoc; }\n\npublic:\n static EnumCaseDecl *create(SourceLoc CaseLoc,\n ArrayRef Elements,\n DeclContext *DC);\n \n \/\/\/ Get the list of elements declared in this case.\n ArrayRef getElements() const {\n return {getTrailingObjects(),\n Bits.EnumCaseDecl.NumElements};\n }\n SourceRange getSourceRange() const;\n \n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::EnumCase;\n }\n};\n\n\/\/\/ This represents a single case of an 'enum' declaration.\n\/\/\/\n\/\/\/ For example, the X, Y, and Z in this enum:\n\/\/\/\n\/\/\/ \\code\n\/\/\/ enum V {\n\/\/\/ case X(Int), Y(Int)\n\/\/\/ case Z\n\/\/\/ }\n\/\/\/ \\endcode\n\/\/\/\n\/\/\/ The type of an EnumElementDecl is always the EnumType for the containing\n\/\/\/ enum. EnumElementDecls are represented in the AST as members of their\n\/\/\/ parent EnumDecl, although syntactically they are subordinate to the\n\/\/\/ EnumCaseDecl.\nclass EnumElementDecl : public DeclContext, public ValueDecl {\n friend class EnumRawValuesRequest;\n \n \/\/\/ This is the type specified with the enum element, for\n \/\/\/ example 'Int' in 'case Y(Int)'. This is null if there is no type\n \/\/\/ associated with this element, as in 'case Z' or in all elements of enum\n \/\/\/ definitions.\n ParameterList *Params;\n \n SourceLoc EqualsLoc;\n \n \/\/\/ The raw value literal for the enum element, or null.\n LiteralExpr *RawValueExpr;\n\npublic:\n EnumElementDecl(SourceLoc IdentifierLoc, DeclName Name,\n ParameterList *Params,\n SourceLoc EqualsLoc,\n LiteralExpr *RawValueExpr,\n DeclContext *DC);\n\n \/\/\/ Returns the string for the base name, or \"_\" if this is unnamed.\n StringRef getNameStr() const {\n assert(!getName().isSpecial() && \"Cannot get string for special names\");\n return hasName() ? getBaseIdentifier().str() : \"_\";\n }\n\n Type getArgumentInterfaceType() const;\n\n void setParameterList(ParameterList *params);\n ParameterList *getParameterList() const { return Params; }\n\n \/\/\/ Retrieves a fully typechecked raw value expression associated\n \/\/\/ with this enum element, if it exists.\n LiteralExpr *getRawValueExpr() const;\n \n \/\/\/ Retrieves a \"structurally\" checked raw value expression associated\n \/\/\/ with this enum element, if it exists.\n \/\/\/\n \/\/\/ The structural raw value may or may not have a type set, but it is\n \/\/\/ guaranteed to be suitable for retrieving any non-semantic information\n \/\/\/ like digit text for an integral raw value or user text for a string raw value.\n LiteralExpr *getStructuralRawValueExpr() const;\n \n \/\/\/ Reset the raw value expression.\n void setRawValueExpr(LiteralExpr *e);\n\n \/\/\/ Return the containing EnumDecl.\n EnumDecl *getParentEnum() const {\n return cast(getDeclContext());\n }\n \n \/\/\/ Return the containing EnumCaseDecl.\n EnumCaseDecl *getParentCase() const;\n\n SourceLoc getStartLoc() const {\n return getNameLoc();\n }\n SourceRange getSourceRange() const;\n \n bool hasAssociatedValues() const {\n return getParameterList() != nullptr;\n }\n\n \/\/\/ True if the case is marked 'indirect'.\n bool isIndirect() const {\n return getAttrs().hasAttribute();\n }\n \n \/\/\/ Do not call this!\n \/\/\/ It exists to let the AST walkers get the raw value without forcing a request.\n LiteralExpr *getRawValueUnchecked() const { return RawValueExpr; }\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::EnumElement;\n }\n\n static bool classof(const DeclContext *DC) {\n if (auto D = DC->getAsDecl())\n return classof(D);\n return false;\n }\n\n using DeclContext::operator new;\n using Decl::getASTContext;\n};\n \ninline SourceRange EnumCaseDecl::getSourceRange() const {\n auto subRange = getElements().back()->getSourceRange();\n if (subRange.isValid())\n return {CaseLoc, subRange.End};\n return {};\n}\n\n\/\/\/ Describes the kind of initializer.\nenum class CtorInitializerKind {\n \/\/\/ A designated initializer is an initializer responsible for initializing\n \/\/\/ the stored properties of the current class and chaining to a superclass's\n \/\/\/ designated initializer (for non-root classes).\n \/\/\/\n \/\/\/ Designated initializers are never inherited.\n Designated,\n\n \/\/\/ A convenience initializer is an initializer that initializes a complete\n \/\/\/ object by delegating to another initializer (eventually reaching a\n \/\/\/ designated initializer).\n \/\/\/\n \/\/\/ Convenience initializers are inherited into subclasses that override\n \/\/\/ all of their superclass's designated initializers.\n Convenience,\n\n \/\/\/ A convenience factory initializer is a convenience initializer introduced\n \/\/\/ by an imported Objective-C factory method.\n \/\/\/\n \/\/\/ Convenience factory initializers cannot be expressed directly in\n \/\/\/ Swift; rather, they are produced by the Clang importer when importing\n \/\/\/ an instancetype factory method from Objective-C.\n ConvenienceFactory,\n\n \/\/\/ A factory initializer is an initializer that is neither designated nor\n \/\/\/ convenience: it can be used to create an object of the given type, but\n \/\/\/ cannot be chained to via \"super.init\" nor is it inherited.\n \/\/\/\n \/\/\/ A factory initializer is written with a return type of the class name\n \/\/\/ itself. FIXME: However, this is only a presentation form, and at present\n \/\/\/ the only factory initializers are produced by importing an Objective-C\n \/\/\/ factory method that does not return instancetype.\n \/\/\/\n \/\/\/ FIXME: Arguably, structs and enums only have factory initializers, and\n \/\/\/ using designated initializers for them is a misnomer.\n Factory\n};\n\n\/\/\/ ConstructorDecl - Declares a constructor for a type. For example:\n\/\/\/\n\/\/\/ \\code\n\/\/\/ struct X {\n\/\/\/ var x : Int\n\/\/\/ init(i : Int) {\n\/\/\/ x = i\n\/\/\/ }\n\/\/\/ }\n\/\/\/ \\endcode\nclass ConstructorDecl : public AbstractFunctionDecl {\n \/\/\/ The location of the '!' or '?' for a failable initializer.\n SourceLoc FailabilityLoc;\n\n ParamDecl *SelfDecl;\n\n \/\/\/ The interface type of the initializing constructor.\n Type InitializerInterfaceType;\n\n \/\/\/ The typechecked call to super.init expression, which needs to be\n \/\/\/ inserted at the end of the initializer by SILGen.\n Expr *CallToSuperInit = nullptr;\n\npublic:\n ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc, \n bool Failable, SourceLoc FailabilityLoc,\n bool Throws, SourceLoc ThrowsLoc,\n ParameterList *BodyParams,\n GenericParamList *GenericParams, \n DeclContext *Parent);\n\n SourceLoc getConstructorLoc() const { return getNameLoc(); }\n SourceLoc getStartLoc() const { return getConstructorLoc(); }\n SourceRange getSourceRange() const;\n\n \/\/\/ Get the interface type of the constructed object.\n Type getResultInterfaceType() const;\n\n \/\/\/ Get the interface type of the initializing constructor.\n Type getInitializerInterfaceType();\n\n \/\/\/ Get the typechecked call to super.init expression, which needs to be\n \/\/\/ inserted at the end of the initializer by SILGen.\n Expr *getSuperInitCall() { return CallToSuperInit; }\n void setSuperInitCall(Expr *CallExpr) { CallToSuperInit = CallExpr; }\n\n ParamDecl **getImplicitSelfDeclStorage() { return &SelfDecl; }\n\n \/\/\/ Specifies the kind of initialization call performed within the body\n \/\/\/ of the constructor, e.g., self.init or super.init.\n enum class BodyInitKind {\n \/\/\/ There are no calls to self.init or super.init.\n None,\n \/\/\/ There is a call to self.init, which delegates to another (peer)\n \/\/\/ initializer.\n Delegating,\n \/\/\/ There is a call to super.init, which chains to a superclass initializer.\n Chained,\n \/\/\/ There are no calls to self.init or super.init explicitly in the body of\n \/\/\/ the constructor, but a 'super.init' call will be implicitly added\n \/\/\/ by semantic analysis.\n ImplicitChained\n };\n\n \/\/\/ Determine whether the body of this constructor contains any delegating\n \/\/\/ or superclass initializations (\\c self.init or \\c super.init,\n \/\/\/ respectively) within its body.\n \/\/\/\n \/\/\/ \\param diags If non-null, this check will ensure that the constructor\n \/\/\/ body is consistent in its use of delegation vs. chaining and emit any\n \/\/\/ diagnostics through the given diagnostic engine.\n \/\/\/\n \/\/\/ \\param init If non-null and there is an explicit \\c self.init or\n \/\/\/ \\c super.init within the body, will be set to point at that\n \/\/\/ initializer.\n BodyInitKind getDelegatingOrChainedInitKind(DiagnosticEngine *diags,\n ApplyExpr **init = nullptr) const;\n void clearCachedDelegatingOrChainedInitKind() {\n Bits.ConstructorDecl.ComputedBodyInitKind = 0;\n }\n\n \/\/\/ Whether this constructor is required.\n bool isRequired() const {\n return getAttrs().hasAttribute();\n }\n\n \/\/\/ Determine the kind of initializer this is.\n CtorInitializerKind getInitKind() const;\n\n \/\/\/ Whether this is a designated initializer.\n bool isDesignatedInit() const {\n return getInitKind() == CtorInitializerKind::Designated;\n }\n\n \/\/\/ Whether this is a convenience initializer.\n bool isConvenienceInit() const {\n return getInitKind() == CtorInitializerKind::Convenience ||\n getInitKind() == CtorInitializerKind::ConvenienceFactory;\n }\n\n \/\/\/ Whether this is a factory initializer.\n bool isFactoryInit() const {\n switch (getInitKind()) {\n case CtorInitializerKind::Designated:\n case CtorInitializerKind::Convenience:\n return false;\n \n case CtorInitializerKind::Factory:\n case CtorInitializerKind::ConvenienceFactory:\n return true;\n }\n llvm_unreachable(\"bad CtorInitializerKind\");\n }\n\n \/\/\/ Determine whether this initializer is inheritable.\n bool isInheritable() const {\n switch (getInitKind()) {\n case CtorInitializerKind::Designated:\n case CtorInitializerKind::Factory:\n return false;\n\n case CtorInitializerKind::Convenience:\n case CtorInitializerKind::ConvenienceFactory:\n return true;\n }\n llvm_unreachable(\"bad CtorInitializerKind\");\n }\n\n \/\/\/ Determine if this is a failable initializer.\n bool isFailable() const {\n return Bits.ConstructorDecl.Failable;\n }\n\n \/\/\/ Retrieve the location of the '!' or '?' in a failable initializer.\n SourceLoc getFailabilityLoc() const { return FailabilityLoc; }\n\n \/\/\/ Whether the implementation of this method is a stub that traps at runtime.\n bool hasStubImplementation() const {\n return Bits.ConstructorDecl.HasStubImplementation;\n }\n\n \/\/\/ Set whether the implementation of this method is a stub that\n \/\/\/ traps at runtime.\n void setStubImplementation(bool stub) {\n Bits.ConstructorDecl.HasStubImplementation = stub;\n }\n\n ConstructorDecl *getOverriddenDecl() const {\n return cast_or_null(\n AbstractFunctionDecl::getOverriddenDecl());\n }\n\n \/\/\/ Determine whether this initializer falls into the special case for\n \/\/\/ Objective-C initializers with selectors longer than \"init\", e.g.,\n \/\/\/ \\c initForMemory.\n \/\/\/\n \/\/\/ In such cases, one can write the Swift initializer\n \/\/\/ with a single parameter of type '()', e.g,\n \/\/\/\n \/\/\/ \\code\n \/\/\/ @objc init(forMemory: ())\n \/\/\/ \\endcode\n bool isObjCZeroParameterWithLongSelector() const;\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::Constructor;\n }\n static bool classof(const AbstractFunctionDecl *D) {\n return classof(static_cast(D));\n }\n static bool classof(const DeclContext *DC) {\n if (auto D = DC->getAsDecl())\n return classof(D);\n return false;\n }\n};\n\n\/\/\/ DestructorDecl - Declares a destructor for a type. For example:\n\/\/\/\n\/\/\/ \\code\n\/\/\/ struct X {\n\/\/\/ var fd : Int\n\/\/\/ deinit {\n\/\/\/ close(fd)\n\/\/\/ }\n\/\/\/ }\n\/\/\/ \\endcode\nclass DestructorDecl : public AbstractFunctionDecl {\n ParamDecl *SelfDecl;\n\npublic:\n DestructorDecl(SourceLoc DestructorLoc, DeclContext *Parent);\n\n ParamDecl **getImplicitSelfDeclStorage() { return &SelfDecl; }\n\n SourceLoc getDestructorLoc() const { return getNameLoc(); }\n SourceLoc getStartLoc() const { return getDestructorLoc(); }\n SourceRange getSourceRange() const;\n\n \/\/\/ Retrieve the Objective-C selector for destructors.\n ObjCSelector getObjCSelector() const;\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::Destructor;\n }\n static bool classof(const AbstractFunctionDecl *D) {\n return classof(static_cast(D));\n }\n static bool classof(const DeclContext *DC) {\n if (auto D = DC->getAsDecl())\n return classof(D);\n return false;\n }\n};\n\n\/\/\/ Declares a precedence group. For example:\n\/\/\/\n\/\/\/ \\code\n\/\/\/ precedencegroup MultiplicativePrecedence {\n\/\/\/ associativity: right\n\/\/\/ higherThan: AdditivePrecedence\n\/\/\/ }\n\/\/\/ \\endcode\nclass PrecedenceGroupDecl : public Decl {\npublic:\n struct Relation {\n SourceLoc NameLoc;\n Identifier Name;\n PrecedenceGroupDecl *Group;\n };\n\nprivate:\n SourceLoc PrecedenceGroupLoc, NameLoc, LBraceLoc, RBraceLoc;\n SourceLoc AssociativityKeywordLoc, AssociativityValueLoc;\n SourceLoc AssignmentKeywordLoc, AssignmentValueLoc;\n SourceLoc HigherThanLoc, LowerThanLoc;\n Identifier Name;\n unsigned NumHigherThan, NumLowerThan;\n \/\/ Tail-allocated array of Relations\n\n Relation *getHigherThanBuffer() {\n return reinterpret_cast(this + 1);\n }\n const Relation *getHigherThanBuffer() const {\n return reinterpret_cast(this + 1);\n }\n Relation *getLowerThanBuffer() {\n return getHigherThanBuffer() + NumHigherThan;\n }\n const Relation *getLowerThanBuffer() const {\n return getHigherThanBuffer() + NumHigherThan;\n }\n\n PrecedenceGroupDecl(DeclContext *DC,\n SourceLoc precedenceGroupLoc,\n SourceLoc nameLoc, Identifier name,\n SourceLoc lbraceLoc,\n SourceLoc associativityKeywordLoc,\n SourceLoc associativityValueLoc,\n Associativity associativity,\n SourceLoc assignmentKeywordLoc,\n SourceLoc assignmentValueLoc,\n bool isAssignment,\n SourceLoc higherThanLoc, ArrayRef higherThan,\n SourceLoc lowerThanLoc, ArrayRef lowerThan,\n SourceLoc rbraceLoc);\n friend class Decl;\n SourceLoc getLocFromSource() const { return NameLoc; }\npublic:\n static PrecedenceGroupDecl *create(DeclContext *dc,\n SourceLoc precedenceGroupLoc,\n SourceLoc nameLoc,\n Identifier name,\n SourceLoc lbraceLoc,\n SourceLoc associativityKeywordLoc,\n SourceLoc associativityValueLoc,\n Associativity associativity,\n SourceLoc assignmentKeywordLoc,\n SourceLoc assignmentValueLoc,\n bool isAssignment,\n SourceLoc higherThanLoc,\n ArrayRef higherThan,\n SourceLoc lowerThanLoc,\n ArrayRef lowerThan,\n SourceLoc rbraceLoc);\n\n\n SourceRange getSourceRange() const {\n return { PrecedenceGroupLoc, RBraceLoc };\n }\n\n \/\/\/ Return the location of 'precedencegroup' in:\n \/\/\/ precedencegroup MultiplicativePrecedence { ... }\n SourceLoc getPrecedenceGroupLoc() const { return PrecedenceGroupLoc; }\n\n \/\/\/ Return the location of 'MultiplicativePrecedence' in:\n \/\/\/ precedencegroup MultiplicativePrecedence { ... }\n SourceLoc getNameLoc() const {\n return NameLoc;\n }\n\n Identifier getName() const {\n return Name;\n }\n\n \/\/ This is needed to allow templated code to work with both ValueDecls and\n \/\/ PrecedenceGroupDecls.\n DeclBaseName getBaseName() const { return Name; }\n\n SourceLoc getLBraceLoc() const { return LBraceLoc; }\n SourceLoc getRBraceLoc() const { return RBraceLoc; }\n\n bool isAssociativityImplicit() const {\n return AssociativityKeywordLoc.isInvalid();\n }\n\n \/\/\/ Return the location of 'associativity' in:\n \/\/\/ associativity: left\n SourceLoc getAssociativityKeywordLoc() const {\n return AssociativityKeywordLoc;\n }\n\n \/\/\/ Return the location of 'right' in:\n \/\/\/ associativity: right\n SourceLoc getAssociativityValueLoc() const {\n return AssociativityValueLoc;\n }\n\n Associativity getAssociativity() const {\n return Associativity(Bits.PrecedenceGroupDecl.Associativity);\n }\n bool isLeftAssociative() const {\n return getAssociativity() == Associativity::Left;\n }\n bool isRightAssociative() const {\n return getAssociativity() == Associativity::Right;\n }\n bool isNonAssociative() const {\n return getAssociativity() == Associativity::None;\n }\n\n bool isAssignmentImplicit() const {\n return AssignmentKeywordLoc.isInvalid();\n }\n\n \/\/\/ Return the location of 'assignment' in:\n \/\/\/ assignment: true\n SourceLoc getAssignmentKeywordLoc() const {\n return AssignmentKeywordLoc;\n }\n\n \/\/\/ Return the location of 'assignment' in:\n \/\/\/ assignment: true\n SourceLoc getAssignmentValueLoc() const {\n return AssignmentValueLoc;\n }\n\n bool isAssignment() const {\n return Bits.PrecedenceGroupDecl.IsAssignment;\n }\n\n bool isHigherThanImplicit() const {\n return HigherThanLoc.isInvalid();\n }\n\n \/\/\/ Return the location of 'higherThan' in:\n \/\/\/ higherThan: AdditivePrecedence\n SourceLoc getHigherThanLoc() const {\n return HigherThanLoc;\n }\n\n ArrayRef getHigherThan() const {\n return { getHigherThanBuffer(), NumHigherThan };\n }\n MutableArrayRef getMutableHigherThan() {\n return { getHigherThanBuffer(), NumHigherThan };\n }\n\n bool isLowerThanImplicit() const {\n return LowerThanLoc.isInvalid();\n }\n\n \/\/\/ Return the location of 'lowerThan' in:\n \/\/\/ lowerThan: MultiplicativePrecedence\n SourceLoc getLowerThanLoc() const {\n return LowerThanLoc;\n }\n\n ArrayRef getLowerThan() const {\n return { getLowerThanBuffer(), NumLowerThan };\n }\n MutableArrayRef getMutableLowerThan() {\n return { getLowerThanBuffer(), NumLowerThan };\n }\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::PrecedenceGroup;\n }\n};\n\n\/\/\/ The fixity of an OperatorDecl.\nenum class OperatorFixity : uint8_t {\n Infix,\n Prefix,\n Postfix\n};\n\ninline void simple_display(llvm::raw_ostream &out, OperatorFixity fixity) {\n switch (fixity) {\n case OperatorFixity::Infix:\n out << \"infix\";\n return;\n case OperatorFixity::Prefix:\n out << \"prefix\";\n return;\n case OperatorFixity::Postfix:\n out << \"postfix\";\n return;\n }\n llvm_unreachable(\"Unhandled case in switch\");\n}\n\n\/\/\/ Abstract base class of operator declarations.\nclass OperatorDecl : public Decl {\n SourceLoc OperatorLoc, NameLoc;\n \n Identifier name;\n\n ArrayRef> Identifiers;\n ArrayRef DesignatedNominalTypes;\n SourceLoc getLocFromSource() const { return NameLoc; }\n friend class Decl;\npublic:\n OperatorDecl(DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc,\n Identifier Name, SourceLoc NameLoc,\n ArrayRef> Identifiers)\n : Decl(kind, DC), OperatorLoc(OperatorLoc), NameLoc(NameLoc), name(Name),\n Identifiers(Identifiers) {}\n\n OperatorDecl(DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc,\n Identifier Name, SourceLoc NameLoc,\n ArrayRef DesignatedNominalTypes)\n : Decl(kind, DC), OperatorLoc(OperatorLoc), NameLoc(NameLoc), name(Name),\n DesignatedNominalTypes(DesignatedNominalTypes) {}\n\n \/\/\/ Retrieve the operator's fixity, corresponding to the concrete subclass\n \/\/\/ of the OperatorDecl.\n OperatorFixity getFixity() const {\n switch (getKind()) {\n#define DECL(Id, Name) case DeclKind::Id: llvm_unreachable(\"Not an operator!\");\n#define OPERATOR_DECL(Id, Name)\n#include \"swift\/AST\/DeclNodes.def\"\n case DeclKind::InfixOperator:\n return OperatorFixity::Infix;\n case DeclKind::PrefixOperator:\n return OperatorFixity::Prefix;\n case DeclKind::PostfixOperator:\n return OperatorFixity::Postfix;\n }\n llvm_unreachable(\"inavlid decl kind\");\n }\n\n SourceLoc getOperatorLoc() const { return OperatorLoc; }\n SourceLoc getNameLoc() const { return NameLoc; }\n Identifier getName() const { return name; }\n\n \/\/ This is needed to allow templated code to work with both ValueDecls and\n \/\/ OperatorDecls.\n DeclBaseName getBaseName() const { return name; }\n\n \/\/\/ Get the list of identifiers after the colon in the operator declaration.\n \/\/\/\n \/\/\/ This list includes the names of designated types. For infix operators, the\n \/\/\/ first item in the list is a precedence group instead.\n \/\/\/\n \/\/\/ \\todo These two purposes really ought to be in separate properties and the\n \/\/\/ designated type list should be of TypeReprs instead of Identifiers.\n ArrayRef> getIdentifiers() const {\n return Identifiers;\n }\n\n ArrayRef getDesignatedNominalTypes() const {\n return DesignatedNominalTypes;\n }\n\n void setDesignatedNominalTypes(ArrayRef nominalTypes) {\n DesignatedNominalTypes = nominalTypes;\n }\n\n static bool classof(const Decl *D) {\n \/\/ Workaround: http:\/\/llvm.org\/PR35906\n if (DeclKind::Last_Decl == DeclKind::Last_OperatorDecl)\n return D->getKind() >= DeclKind::First_OperatorDecl;\n return D->getKind() >= DeclKind::First_OperatorDecl\n && D->getKind() <= DeclKind::Last_OperatorDecl;\n }\n};\n\n\/\/\/ Declares the behavior of an infix operator. For example:\n\/\/\/\n\/\/\/ \\code\n\/\/\/ infix operator \/+\/ : AdditionPrecedence, Numeric\n\/\/\/ \\endcode\nclass InfixOperatorDecl : public OperatorDecl {\n SourceLoc ColonLoc;\n\npublic:\n InfixOperatorDecl(DeclContext *DC, SourceLoc operatorLoc, Identifier name,\n SourceLoc nameLoc, SourceLoc colonLoc,\n ArrayRef> identifiers)\n : OperatorDecl(DeclKind::InfixOperator, DC, operatorLoc, name, nameLoc,\n identifiers),\n ColonLoc(colonLoc) {}\n\n SourceLoc getEndLoc() const {\n auto identifiers = getIdentifiers();\n if (identifiers.empty())\n return getNameLoc();\n\n return identifiers.back().Loc;\n }\n\n SourceRange getSourceRange() const {\n return { getOperatorLoc(), getEndLoc() };\n }\n\n SourceLoc getColonLoc() const { return ColonLoc; }\n\n PrecedenceGroupDecl *getPrecedenceGroup() const;\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::InfixOperator;\n }\n};\n \n\/\/\/ Declares the behavior of a prefix operator. For example:\n\/\/\/\n\/\/\/ \\code\n\/\/\/ prefix operator \/+\/ {}\n\/\/\/ \\endcode\nclass PrefixOperatorDecl : public OperatorDecl {\npublic:\n PrefixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,\n SourceLoc NameLoc,\n ArrayRef> Identifiers)\n : OperatorDecl(DeclKind::PrefixOperator, DC, OperatorLoc, Name, NameLoc,\n Identifiers) {}\n\n PrefixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,\n SourceLoc NameLoc,\n ArrayRef designatedNominalTypes)\n : OperatorDecl(DeclKind::PrefixOperator, DC, OperatorLoc, Name, NameLoc,\n designatedNominalTypes) {}\n\n SourceRange getSourceRange() const {\n return { getOperatorLoc(), getNameLoc() };\n }\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::PrefixOperator;\n }\n};\n \n\/\/\/ Declares the behavior of a postfix operator. For example:\n\/\/\/\n\/\/\/ \\code\n\/\/\/ postfix operator \/+\/ {}\n\/\/\/ \\endcode\nclass PostfixOperatorDecl : public OperatorDecl {\npublic:\n PostfixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,\n SourceLoc NameLoc,\n ArrayRef> Identifiers)\n : OperatorDecl(DeclKind::PostfixOperator, DC, OperatorLoc, Name, NameLoc,\n Identifiers) {}\n\n PostfixOperatorDecl(DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,\n SourceLoc NameLoc,\n ArrayRef designatedNominalTypes)\n : OperatorDecl(DeclKind::PostfixOperator, DC, OperatorLoc, Name, NameLoc,\n designatedNominalTypes) {}\n\n SourceRange getSourceRange() const {\n return { getOperatorLoc(), getNameLoc() };\n }\n \n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::PostfixOperator;\n }\n};\n\n\/\/\/ Represents a hole where a declaration should have been.\n\/\/\/\n\/\/\/ Among other things, these are used to keep vtable layout consistent.\nclass MissingMemberDecl : public Decl {\n DeclName Name;\n\n MissingMemberDecl(DeclContext *DC, DeclName name,\n unsigned vtableEntries,\n unsigned fieldOffsetVectorEntries)\n : Decl(DeclKind::MissingMember, DC), Name(name) {\n Bits.MissingMemberDecl.NumberOfVTableEntries = vtableEntries;\n assert(getNumberOfVTableEntries() == vtableEntries && \"not enough bits\");\n Bits.MissingMemberDecl.NumberOfFieldOffsetVectorEntries =\n fieldOffsetVectorEntries;\n assert(getNumberOfFieldOffsetVectorEntries() == fieldOffsetVectorEntries\n && \"not enough bits\");\n setImplicit();\n }\n friend class Decl;\n SourceLoc getLocFromSource() const {\n return SourceLoc();\n }\npublic:\n static MissingMemberDecl *\n create(ASTContext &ctx, DeclContext *DC, DeclName name,\n unsigned numVTableEntries, bool hasStorage) {\n assert(!numVTableEntries || isa(DC) || isa(DC) &&\n \"Only classes and protocols have vtable\/witness table entries\");\n assert(!hasStorage || !isa(DC) &&\n \"Protocols cannot have missing stored properties\");\n\n return new (ctx) MissingMemberDecl(DC, name, numVTableEntries, hasStorage);\n }\n\n DeclName getName() const {\n return Name;\n }\n\n unsigned getNumberOfVTableEntries() const {\n return Bits.MissingMemberDecl.NumberOfVTableEntries;\n }\n\n unsigned getNumberOfFieldOffsetVectorEntries() const {\n return Bits.MissingMemberDecl.NumberOfFieldOffsetVectorEntries;\n }\n\n SourceRange getSourceRange() const {\n return SourceRange();\n }\n\n static bool classof(const Decl *D) {\n return D->getKind() == DeclKind::MissingMember;\n }\n};\n\ninline bool AbstractStorageDecl::isSettable(const DeclContext *UseDC,\n const DeclRefExpr *base) const {\n if (auto vd = dyn_cast(this))\n return vd->isSettable(UseDC, base);\n\n auto sd = cast(this);\n return sd->supportsMutation();\n}\n\ninline void\nAbstractStorageDecl::overwriteSetterAccess(AccessLevel accessLevel) {\n Accessors.setInt(accessLevel);\n if (auto setter = getAccessor(AccessorKind::Set))\n setter->overwriteAccess(accessLevel);\n if (auto modify = getAccessor(AccessorKind::Modify))\n modify->overwriteAccess(accessLevel);\n if (auto mutableAddressor = getAccessor(AccessorKind::MutableAddress))\n mutableAddressor->overwriteAccess(accessLevel);\n}\n\n\/\/\/ Constructors and destructors always have a 'self' parameter,\n\/\/\/ which is stored in an instance member. Functions only have a\n\/\/\/ 'self' if they are declared inside of a nominal type or extension,\n\/\/\/ in which case we tail-allocate storage for it.\ninline ParamDecl **AbstractFunctionDecl::getImplicitSelfDeclStorage() {\n switch (getKind()) {\n default: llvm_unreachable(\"Unknown AbstractFunctionDecl!\");\n case DeclKind::Constructor:\n return cast(this)->getImplicitSelfDeclStorage();\n case DeclKind::Destructor:\n return cast(this)->getImplicitSelfDeclStorage();\n case DeclKind::Func:\n case DeclKind::Accessor:\n return cast(this)->getImplicitSelfDeclStorage();\n }\n}\n\ninline ParamDecl **FuncDecl::getImplicitSelfDeclStorage() {\n if (!hasImplicitSelfDecl())\n return nullptr;\n\n if (!isa(this)) {\n assert(getKind() == DeclKind::Func && \"no new kinds of functions\");\n return reinterpret_cast(this+1);\n }\n return reinterpret_cast(static_cast(this)+1);\n}\n\ninline DeclIterator &DeclIterator::operator++() {\n Current = Current->NextDecl;\n return *this;\n}\n\ninline bool AbstractFunctionDecl::hasForcedStaticDispatch() const {\n if (auto func = dyn_cast(this))\n return func->hasForcedStaticDispatch();\n return false;\n}\n\ninline bool ValueDecl::isStatic() const {\n \/\/ Currently, only storage and function decls can be static\/class.\n if (auto storage = dyn_cast(this))\n return storage->isStatic();\n if (auto func = dyn_cast(this))\n return func->isStatic();\n return false;\n}\n\ninline bool ValueDecl::isImportAsMember() const {\n if (auto func = dyn_cast(this))\n return func->isImportAsMember();\n return false;\n}\n\ninline bool ValueDecl::hasCurriedSelf() const {\n if (auto *afd = dyn_cast(this))\n return afd->hasImplicitSelfDecl();\n if (isa(this))\n return true;\n return false;\n}\n\ninline bool ValueDecl::hasParameterList() const {\n if (auto *eed = dyn_cast(this))\n return eed->hasAssociatedValues();\n return isa(this) || isa(this);\n}\n\ninline unsigned ValueDecl::getNumCurryLevels() const {\n unsigned curryLevels = 0;\n if (hasParameterList())\n curryLevels++;\n if (hasCurriedSelf())\n curryLevels++;\n return curryLevels;\n}\n\ninline bool Decl::isPotentiallyOverridable() const {\n if (isa(this) ||\n isa(this) ||\n isa(this) ||\n isa(this)) {\n return getDeclContext()->getSelfClassDecl();\n } else {\n return false;\n }\n}\n\ninline GenericParamKey::GenericParamKey(const GenericTypeParamDecl *d)\n : Depth(d->getDepth()), Index(d->getIndex()) { }\n\ninline const GenericContext *Decl::getAsGenericContext() const {\n switch (getKind()) {\n default: return nullptr;\n#define DECL(Id, Parent) \/\/ See previous line\n#define GENERIC_DECL(Id, Parent) \\\n case DeclKind::Id: \\\n return static_cast(this);\n#include \"swift\/AST\/DeclNodes.def\"\n }\n}\n\ninline bool DeclContext::classof(const Decl *D) {\n switch (D->getKind()) { \/\/\n default: return false;\n#define DECL(ID, PARENT) \/\/ See previous line\n#define CONTEXT_DECL(ID, PARENT) \\\n case DeclKind::ID: return true;\n#include \"swift\/AST\/DeclNodes.def\"\n }\n}\n\ninline DeclContext *DeclContext::castDeclToDeclContext(const Decl *D) {\n \/\/ XXX -- ModuleDecl is not defined in Decl.h, but because DeclContexts\n \/\/ preface decls in memory, any DeclContext type will due.\n const DeclContext *DC = static_cast(D);\n switch (D->getKind()) {\n default: llvm_unreachable(\"Not a DeclContext\");\n#define DECL(ID, PARENT) \/\/ See previous line\n#define CONTEXT_DECL(ID, PARENT) \\\n case DeclKind::ID:\n#include \"swift\/AST\/DeclNodes.def\"\n return const_cast(DC);\n }\n}\n\ninline EnumElementDecl *EnumDecl::getUniqueElement(bool hasValue) const {\n EnumElementDecl *result = nullptr;\n bool found = false;\n for (auto elt : getAllElements()) {\n if (elt->hasAssociatedValues() == hasValue) {\n if (found)\n return nullptr;\n found = true;\n result = elt;\n }\n }\n return result;\n}\n\n\/\/\/ Retrieve the parameter list for a given declaration, or nullputr if there\n\/\/\/ is none.\nParameterList *getParameterList(ValueDecl *source);\n\n\/\/\/ Retrieve parameter declaration from the given source at given index, or\n\/\/\/ nullptr if the source does not have a parameter list.\nconst ParamDecl *getParameterAt(const ValueDecl *source, unsigned index);\n\nvoid simple_display(llvm::raw_ostream &out,\n OptionSet options);\n\n\/\/\/ Display Decl subclasses.\nvoid simple_display(llvm::raw_ostream &out, const Decl *decl);\n\n\/\/\/ Display ValueDecl subclasses.\nvoid simple_display(llvm::raw_ostream &out, const ValueDecl *decl);\n\n\/\/\/ Display ExtensionDecls.\ninline void simple_display(llvm::raw_ostream &out, const ExtensionDecl *decl) {\n simple_display(out, static_cast(decl));\n}\n\n\/\/\/ Display NominalTypeDecls.\ninline void simple_display(llvm::raw_ostream &out,\n const NominalTypeDecl *decl) {\n simple_display(out, static_cast(decl));\n}\n\ninline void simple_display(llvm::raw_ostream &out,\n const AssociatedTypeDecl *decl) {\n simple_display(out, static_cast(decl));\n}\n\n\/\/\/ Display GenericContext.\n\/\/\/\n\/\/\/ The template keeps this sorted down in the overload set relative to the\n\/\/\/ more concrete overloads with Decl pointers thereby breaking a potential ambiguity.\ntemplate \ninline typename std::enable_if::value>::type\nsimple_display(llvm::raw_ostream &out, const T *GC) {\n simple_display(out, GC->getAsDecl());\n}\n\n\/\/\/ Display GenericParamList.\nvoid simple_display(llvm::raw_ostream &out, const GenericParamList *GPL);\n\n\/\/\/ Extract the source location from the given declaration.\nSourceLoc extractNearestSourceLoc(const Decl *decl);\n\n\/\/\/ Extract the source location from the given declaration.\ninline SourceLoc extractNearestSourceLoc(const ExtensionDecl *ext) {\n return extractNearestSourceLoc(static_cast(ext));\n}\n\n\/\/\/ Extract the source location from the given declaration.\ninline SourceLoc extractNearestSourceLoc(const GenericTypeDecl *type) {\n return extractNearestSourceLoc(static_cast(type));\n}\n\n\/\/\/ Extract the source location from the given declaration.\ninline SourceLoc extractNearestSourceLoc(const NominalTypeDecl *type) {\n return extractNearestSourceLoc(static_cast(type));\n}\n\n\/\/\/ Extract the source location from the given declaration.\ninline SourceLoc extractNearestSourceLoc(const AbstractFunctionDecl *func) {\n return extractNearestSourceLoc(static_cast(func));\n}\n\n} \/\/ end namespace swift\n\n#endif\n","avg_line_length":35.1366305624,"max_line_length":104,"alphanum_fraction":0.7067468394} +{"size":3978,"ext":"h","lang":"C","max_stars_count":23.0,"content":"\/*\r\n * lber-proto.h\r\n * function prototypes for lber library\r\n *\/\r\n\r\n#ifdef LDAP_DEBUG\r\nextern int lber_debug;\r\n#endif\r\n\r\n#ifndef LDAPFUNCDECL\r\n#ifdef _WIN32\r\n#define LDAPFUNCDECL\t__declspec( dllexport )\r\n#else \/* _WIN32 *\/\r\n#define LDAPFUNCDECL\r\n#endif \/* _WIN32 *\/\r\n#endif \/* LDAPFUNCDECL *\/\r\n\r\n\/*\r\n * in bprint.c:\r\n *\/\r\nLDAPFUNCDECL void lber_bprint( char *data, int len );\r\n\r\n\/*\r\n * in decode.c:\r\n *\/\r\nLDAPFUNCDECL unsigned long ber_get_tag( BerElement *ber );\r\nLDAPFUNCDECL unsigned long ber_skip_tag( BerElement *ber, unsigned long *len );\r\nLDAPFUNCDECL unsigned long ber_peek_tag( BerElement *ber, unsigned long *len );\r\nLDAPFUNCDECL unsigned long ber_get_int( BerElement *ber, long *num );\r\nLDAPFUNCDECL unsigned long ber_get_stringb( BerElement *ber, char *buf,\r\n\tunsigned long *len );\r\nLDAPFUNCDECL unsigned long ber_get_stringa( BerElement *ber, char **buf );\r\nLDAPFUNCDECL unsigned long ber_get_stringal( BerElement *ber, struct berval **bv );\r\nLDAPFUNCDECL unsigned long ber_get_bitstringa( BerElement *ber, char **buf,\r\n\tunsigned long *len );\r\nLDAPFUNCDECL unsigned long ber_get_null( BerElement *ber );\r\nLDAPFUNCDECL unsigned long ber_get_boolean( BerElement *ber, int *boolval );\r\nLDAPFUNCDECL unsigned long ber_first_element( BerElement *ber, unsigned long *len,\r\n\tchar **last );\r\nLDAPFUNCDECL unsigned long ber_next_element( BerElement *ber, unsigned long *len,\r\n\tchar *last );\r\n#if defined( MACOS ) || defined( BC31 ) || defined( _WIN32 )\r\nLDAPFUNCDECL unsigned long ber_scanf( BerElement *ber, char *fmt, ... );\r\n#else\r\nLDAPFUNCDECL unsigned long ber_scanf();\r\n#endif\r\nLDAPFUNCDECL void ber_bvfree( struct berval *bv );\r\nLDAPFUNCDECL void ber_bvecfree( struct berval **bv );\r\nLDAPFUNCDECL struct berval *ber_bvdup( struct berval *bv );\r\n#ifdef STR_TRANSLATION\r\nLDAPFUNCDECL void ber_set_string_translators( BerElement *ber,\r\n\tBERTranslateProc encode_proc, BERTranslateProc decode_proc );\r\n#endif \/* STR_TRANSLATION *\/\r\n\r\n\/*\r\n * in encode.c\r\n *\/\r\nLDAPFUNCDECL int ber_put_enum( BerElement *ber, long num, unsigned long tag );\r\nLDAPFUNCDECL int ber_put_int( BerElement *ber, long num, unsigned long tag );\r\nLDAPFUNCDECL int ber_put_ostring( BerElement *ber, char *str, unsigned long len,\r\n\tunsigned long tag );\r\nLDAPFUNCDECL int ber_put_string( BerElement *ber, char *str, unsigned long tag );\r\nLDAPFUNCDECL int ber_put_bitstring( BerElement *ber, char *str,\r\n\tunsigned long bitlen, unsigned long tag );\r\nLDAPFUNCDECL int ber_put_null( BerElement *ber, unsigned long tag );\r\nLDAPFUNCDECL int ber_put_boolean( BerElement *ber, int boolval,\r\n\tunsigned long tag );\r\nLDAPFUNCDECL int ber_start_seq( BerElement *ber, unsigned long tag );\r\nLDAPFUNCDECL int ber_start_set( BerElement *ber, unsigned long tag );\r\nLDAPFUNCDECL int ber_put_seq( BerElement *ber );\r\nLDAPFUNCDECL int ber_put_set( BerElement *ber );\r\n#if defined( MACOS ) || defined( BC31 ) || defined( _WIN32 )\r\nLDAPFUNCDECL int ber_printf( BerElement *ber, char *fmt, ... );\r\n#else\r\nLDAPFUNCDECL int ber_printf();\r\n#endif\r\n\r\n\/*\r\n * in io.c:\r\n *\/\r\nLDAPFUNCDECL long ber_read( BerElement *ber, char *buf, unsigned long len );\r\nLDAPFUNCDECL long ber_write( BerElement *ber, char *buf, unsigned long len,\r\n\tint nosos );\r\nLDAPFUNCDECL void ber_free( BerElement *ber, int freebuf );\r\nLDAPFUNCDECL int ber_flush( Sockbuf *sb, BerElement *ber, int freeit );\r\nLDAPFUNCDECL BerElement *ber_alloc( void );\r\nLDAPFUNCDECL BerElement *der_alloc( void );\r\nLDAPFUNCDECL BerElement *ber_alloc_t( int options );\r\nLDAPFUNCDECL BerElement *ber_dup( BerElement *ber );\r\nLDAPFUNCDECL void ber_dump( BerElement *ber, int inout );\r\nLDAPFUNCDECL void ber_sos_dump( Seqorset *sos );\r\nLDAPFUNCDECL unsigned long ber_get_next( Sockbuf *sb, unsigned long *len,\r\n\tBerElement *ber );\r\nLDAPFUNCDECL void ber_init( BerElement *ber, int options );\r\nLDAPFUNCDECL void ber_reset( BerElement *ber, int was_writing );\r\n\r\n#ifdef NEEDGETOPT\r\n\/*\r\n * in getopt.c\r\n *\/\r\nint getopt( int nargc, char **nargv, char *ostr );\r\n#endif \/* NEEDGETOPT *\/\r\n","avg_line_length":38.6213592233,"max_line_length":84,"alphanum_fraction":0.7425842132} +{"size":1580,"ext":"h","lang":"C","max_stars_count":2.0,"content":"\/* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and\/or modify it under\nthe terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 3, or (at your option) any later\nversion.\n\nGCC is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\nfor more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively. If not, see\n. *\/\n\n#undef STARTFILE_SPEC\n#define STARTFILE_SPEC \\\n \"%{!shared: crt1%O%s} crti%O%s crtbegin%O%s crtlibid%O%s\"\n\n#define TARGET_OS_CPP_BUILTINS() LINUX_TARGET_OS_CPP_BUILTINS()\n\n#define MD_UNWIND_SUPPORT \"config\/bfin\/linux-unwind.h\"\n\n\/* Like the definition in gcc.c, but for purposes of uClinux, every link is\n static. *\/\n#define MFWRAP_SPEC \" %{fmudflap|fmudflapth: \\\n --wrap=malloc --wrap=free --wrap=calloc --wrap=realloc\\\n --wrap=mmap --wrap=munmap --wrap=alloca\\\n %{fmudflapth: --wrap=pthread_create\\\n}} %{fmudflap|fmudflapth: --wrap=main}\"\n\n#undef TARGET_SUPPORTS_SYNC_CALLS\n#define TARGET_SUPPORTS_SYNC_CALLS 1\n","avg_line_length":37.619047619,"max_line_length":75,"alphanum_fraction":0.7715189873} +{"size":53974,"ext":"c","lang":"C","max_stars_count":1.0,"content":"\/* $FreeBSD$ *\/\n\/*\t$NetBSD: msdosfs_vnops.c,v 1.68 1998\/02\/10 14:10:04 mrg Exp $\t*\/\n\n\/*-\n * SPDX-License-Identifier: BSD-4-Clause\n *\n * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.\n * Copyright (C) 1994, 1995, 1997 TooLs GmbH.\n * All rights reserved.\n * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n * 3. All advertising materials mentioning features or use of this software\n * must display the following acknowledgement:\n *\tThis product includes software developed by TooLs GmbH.\n * 4. The name of TooLs GmbH may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR\n * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\n * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\n * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\/\n\/*-\n * Written by Paul Popelka (paulp@uts.amdahl.com)\n *\n * You can do anything you want with this software, just don't say you wrote\n * it, and don't remove this notice.\n *\n * This software is provided \"as is\".\n *\n * The author supplies this software to be publicly redistributed on the\n * understanding that the author is not responsible for the correct\n * functioning of this software in any circumstances and is not liable for\n * any damages caused by this software.\n *\n * October 1992\n *\/\n\n#include \n#include \n#include \n#include \t\/* defines plimit structure in proc struct *\/\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\n#include \n\n#include \n\n#include \n#include \n#include \n#include \n#include \n\n\/*\n * Some general notes:\n *\n * In the ufs filesystem the inodes, superblocks, and indirect blocks are\n * read\/written using the vnode for the filesystem. Blocks that represent\n * the contents of a file are read\/written using the vnode for the file\n * (including directories when they are read\/written as files). This\n * presents problems for the dos filesystem because data that should be in\n * an inode (if dos had them) resides in the directory itself. Since we\n * must update directory entries without the benefit of having the vnode\n * for the directory we must use the vnode for the filesystem. This means\n * that when a directory is actually read\/written (via read, write, or\n * readdir, or seek) we must use the vnode for the filesystem instead of\n * the vnode for the directory as would happen in ufs. This is to insure we\n * retrieve the correct block from the buffer cache since the hash value is\n * based upon the vnode address and the desired block number.\n *\/\n\n\/*\n * Create a regular file. On entry the directory to contain the file being\n * created is locked. We must release before we return. We must also free\n * the pathname buffer pointed at by cnp->cn_pnbuf, always on error, or\n * only if the SAVESTART bit in cn_flags is clear on success.\n *\/\nstatic int\nmsdosfs_create(struct vop_old_create_args *ap)\n{\n\tstruct componentname *cnp = ap->a_cnp;\n\tstruct denode ndirent;\n\tstruct denode *dep;\n\tstruct denode *pdep = VTODE(ap->a_dvp);\n\tstruct timespec ts;\n\tint error;\n\n\tmprintf(\"msdosfs_create(cnp %p, vap %p\\n\", cnp, ap->a_vap);\n\n\t\/*\n\t * If this is the root directory and there is no space left we\n\t * can't do anything. This is because the root directory can not\n\t * change size.\n\t *\/\n\tif (pdep->de_StartCluster == MSDOSFSROOT\n\t && pdep->de_fndoffset >= pdep->de_FileSize) {\n\t\terror = ENOSPC;\n\t\tgoto bad;\n\t}\n\n\t\/*\n\t * Create a directory entry for the file, then call createde() to\n\t * have it installed. NOTE: DOS files are always executable. We\n\t * use the absence of the owner write bit to make the file\n\t * readonly.\n\t *\/\n\tmemset(&ndirent, 0, sizeof(ndirent));\n\terror = uniqdosname(pdep, cnp, ndirent.de_Name);\n\tif (error)\n\t\tgoto bad;\n\n\tndirent.de_Attributes = (ap->a_vap->va_mode & VWRITE) ?\n\t\t\t\tATTR_ARCHIVE : ATTR_ARCHIVE | ATTR_READONLY;\n\tndirent.de_LowerCase = 0;\n\tndirent.de_StartCluster = 0;\n\tndirent.de_FileSize = 0;\n\tndirent.de_dev = pdep->de_dev;\n\tndirent.de_devvp = pdep->de_devvp;\n\tndirent.de_pmp = pdep->de_pmp;\n\tndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;\n\tvfs_timestamp(&ts);\n\tDETIMES(&ndirent, &ts, &ts, &ts);\n\terror = createde(&ndirent, pdep, &dep, cnp);\n\tif (error)\n\t\tgoto bad;\n\t*ap->a_vpp = DETOV(dep);\n\treturn (0);\n\nbad:\n\treturn (error);\n}\n\nstatic int\nmsdosfs_mknod(struct vop_old_mknod_args *ap)\n{\n\treturn (EINVAL);\n}\n\nstatic int\nmsdosfs_open(struct vop_open_args *ap)\n{\n\treturn(vop_stdopen(ap));\n}\n\nstatic int\nmsdosfs_close(struct vop_close_args *ap)\n{\n\tstruct vnode *vp = ap->a_vp;\n\tstruct denode *dep = VTODE(vp);\n\tstruct timespec ts;\n\n\tif (VREFCNT(vp) > 1) {\n\t\tvfs_timestamp(&ts);\n\t\tDETIMES(dep, &ts, &ts, &ts);\n\t}\n\treturn (vop_stdclose(ap));\n}\n\nstatic int\nmsdosfs_access(struct vop_access_args *ap)\n{\n\tstruct denode *dep = VTODE(ap->a_vp);\n\tstruct msdosfsmount *pmp = dep->de_pmp;\n\tmode_t file_mode;\n\n\tfile_mode = (S_IXUSR|S_IXGRP|S_IXOTH) | (S_IRUSR|S_IRGRP|S_IROTH) |\n\t ((dep->de_Attributes & ATTR_READONLY) ?\n\t 0 : (S_IWUSR|S_IWGRP|S_IWOTH));\n\tfile_mode &= (ap->a_vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask);\n\n\treturn (vop_helper_access(ap, pmp->pm_uid, pmp->pm_gid, file_mode, 0));\n}\n\nstatic int\nmsdosfs_getattr(struct vop_getattr_args *ap)\n{\n\tstruct denode *dep = VTODE(ap->a_vp);\n\tstruct msdosfsmount *pmp = dep->de_pmp;\n\tstruct vattr *vap = ap->a_vap;\n\tmode_t mode;\n\tstruct timespec ts;\n\tu_long dirsperblk = pmp->pm_BytesPerSec \/ sizeof(struct direntry);\n\tuint64_t fileid;\n\n\tvfs_timestamp(&ts);\n\tDETIMES(dep, &ts, &ts, &ts);\n\tvap->va_fsid = devid_from_dev(dep->de_dev);\n\t\/*\n\t * The following computation of the fileid must be the same as that\n\t * used in msdosfs_readdir() to compute d_fileno. If not, pwd\n\t * doesn't work.\n\t *\/\n\tif (dep->de_Attributes & ATTR_DIRECTORY) {\n\t\tfileid = (uint64_t)cntobn(pmp, dep->de_StartCluster) *\n\t\t dirsperblk;\n\t\tif (dep->de_StartCluster == MSDOSFSROOT)\n\t\t\tfileid = 1;\n\t} else {\n\t\tfileid = (uint64_t)cntobn(pmp, dep->de_dirclust) *\n\t\t dirsperblk;\n\t\tif (dep->de_dirclust == MSDOSFSROOT)\n\t\t\tfileid = (uint64_t)roottobn(pmp, 0) * dirsperblk;\n\t\tfileid += (uoff_t)dep->de_diroffset \/ sizeof(struct direntry);\n\t}\n\tvap->va_fileid = fileid;\n\tif ((dep->de_Attributes & ATTR_READONLY) == 0)\n\t\tmode = S_IRWXU|S_IRWXG|S_IRWXO;\n\telse\n\t\tmode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;\n\tvap->va_mode = mode &\n\t (ap->a_vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask);\n\tvap->va_uid = pmp->pm_uid;\n\tvap->va_gid = pmp->pm_gid;\n\tvap->va_nlink = 1;\n\tvap->va_rmajor = VNOVAL;\n\tvap->va_rminor = VNOVAL;\n\tvap->va_size = dep->de_FileSize;\n\tfattime2timespec(dep->de_MDate, dep->de_MTime, 0, 0, &vap->va_mtime);\n\tif (pmp->pm_flags & MSDOSFSMNT_LONGNAME) {\n\t\tfattime2timespec(dep->de_ADate, 0, 0, 0, &vap->va_atime);\n\t\tfattime2timespec(dep->de_CDate, dep->de_CTime, dep->de_CHun,\n\t\t 0, &vap->va_ctime);\n\t} else {\n\t\tvap->va_atime = vap->va_mtime;\n\t\tvap->va_ctime = vap->va_mtime;\n\t}\n\tvap->va_flags = 0;\n\tif ((dep->de_Attributes & ATTR_ARCHIVE) == 0)\n\t\tvap->va_flags |= SF_ARCHIVED;\n\tvap->va_gen = 0;\n\tvap->va_blocksize = pmp->pm_bpcluster;\n\tvap->va_bytes =\n\t (dep->de_FileSize + pmp->pm_crbomask) & ~pmp->pm_crbomask;\n\tvap->va_type = ap->a_vp->v_type;\n\tvap->va_filerev = dep->de_modrev;\n\treturn (0);\n}\n\nstatic int\nmsdosfs_setattr(struct vop_setattr_args *ap)\n{\n\tstruct vnode *vp = ap->a_vp;\n\tstruct denode *dep = VTODE(vp);\n\tstruct msdosfsmount *pmp = dep->de_pmp;\n\tstruct vattr *vap = ap->a_vap;\n\tstruct ucred *cred = ap->a_cred;\n\tint error = 0;\n\n\tmprintf(\"msdosfs_setattr(): vp %p, vap %p, cred %p\\n\", vp, vap, cred);\n\n\t\/*\n\t * Check for unsettable attributes.\n\t *\/\n\tif ((vap->va_type != VNON) || (vap->va_nlink != VNOVAL) ||\n\t (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) ||\n\t (vap->va_blocksize != VNOVAL) || (vap->va_rmajor != VNOVAL) ||\n\t (vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) {\n\t\tmprintf(\"msdosfs_setattr(): returning EINVAL\\n\");\n\t\tmprintf(\" va_type %d, va_nlink %llx, va_fsid %llx, va_fileid %llx\\n\",\n\t\t vap->va_type, (unsigned long long)vap->va_nlink,\n\t\t (unsigned long long)vap->va_fsid,\n\t\t (unsigned long long)vap->va_fileid);\n\t\tmprintf(\" va_blocksize %lx, va_rdev %llx, va_bytes %llx, va_gen %lx\\n\",\n\t\t vap->va_blocksize, (unsigned long long)0,\n\t\t (unsigned long long)vap->va_bytes, vap->va_gen);\n\t\tmprintf(\" va_uid %x, va_gid %x\\n\",\n\t\t vap->va_uid, vap->va_gid);\n\t\treturn (EINVAL);\n\t}\n\n\t\/*\n\t * We don't allow setting attributes on the root directory.\n\t * The special case for the root directory is because before\n\t * FAT32, the root directory didn't have an entry for itself\n\t * (and was otherwise special). With FAT32, the root\n\t * directory is not so special, but still doesn't have an\n\t * entry for itself.\n\t *\/\n\tif (vp->v_flag & VROOT)\n\t\treturn (EINVAL);\n\n\tif (vap->va_flags != VNOVAL) {\n\t\tif (vp->v_mount->mnt_flag & MNT_RDONLY)\n\t\t\treturn (EROFS);\n\t\tif (cred->cr_uid != pmp->pm_uid &&\n\t\t (error = priv_check_cred(cred, PRIV_VFS_SETATTR, 0)))\n\t\t\treturn (error);\n\t\t\/*\n\t\t * We are very inconsistent about handling unsupported\n\t\t * attributes. We ignored the access time and the\n\t\t * read and execute bits. We were strict for the other\n\t\t * attributes.\n\t\t *\n\t\t * Here we are strict, stricter than ufs in not allowing\n\t\t * users to attempt to set SF_SETTABLE bits or anyone to\n\t\t * set unsupported bits. However, we ignore attempts to\n\t\t * set ATTR_ARCHIVE for directories `cp -pr' from a more\n\t\t * sensible file system attempts it a lot.\n\t\t *\/\n\t\tif (cred->cr_uid != 0) {\n\t\t\tif (vap->va_flags & SF_SETTABLE)\n\t\t\t\treturn EPERM;\n\t\t}\n\t\tif (vap->va_flags & ~SF_ARCHIVED)\n\t\t\treturn EOPNOTSUPP;\n\t\tif (vap->va_flags & SF_ARCHIVED)\n\t\t\tdep->de_Attributes &= ~ATTR_ARCHIVE;\n\t\telse if (!(dep->de_Attributes & ATTR_DIRECTORY))\n\t\t\tdep->de_Attributes |= ATTR_ARCHIVE;\n\t\tdep->de_flag |= DE_MODIFIED;\n\t}\n\n\tif (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) {\n\t\tuid_t uid;\n\t\tgid_t gid;\n\n\t\tif (vp->v_mount->mnt_flag & MNT_RDONLY)\n\t\t\treturn (EROFS);\n\t\tuid = vap->va_uid;\n\t\tif (uid == (uid_t)VNOVAL)\n\t\t\tuid = pmp->pm_uid;\n\t\tgid = vap->va_gid;\n\t\tif (gid == (gid_t)VNOVAL)\n\t\t\tgid = pmp->pm_gid;\n\t\tif ((cred->cr_uid != pmp->pm_uid || uid != pmp->pm_uid ||\n\t\t (gid != pmp->pm_gid && !groupmember(gid, cred))) &&\n\t\t (error = priv_check_cred(cred, PRIV_VFS_SETATTR, 0)))\n\t\t\treturn error;\n\t\tif (uid != pmp->pm_uid || gid != pmp->pm_gid)\n\t\t\treturn EINVAL;\n\t}\n\n\tif (vap->va_size != VNOVAL) {\n\t\tswitch (vp->v_type) {\n\t\tcase VDIR:\n\t\t\treturn (EISDIR);\n\t\tcase VREG:\n\t\t\t\/*\n\t\t\t * Truncation is only supported for regular files,\n\t\t\t * Disallow it if the filesystem is read-only.\n\t\t\t *\/\n\t\t\tif (vp->v_mount->mnt_flag & MNT_RDONLY)\n\t\t\t\treturn (EROFS);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t\/*\n\t\t\t * According to POSIX, the result is unspecified\n\t\t\t * for file types other than regular files,\n\t\t\t * directories and shared memory objects. We\n\t\t\t * don't support any file types except regular\n\t\t\t * files and directories in this file system, so\n\t\t\t * this (default) case is unreachable and can do\n\t\t\t * anything. Keep falling through to detrunc()\n\t\t\t * for now.\n\t\t\t *\/\n\t\t\tbreak;\n\t\t}\n\t\terror = detrunc(dep, vap->va_size, 0);\n\t\tif (error)\n\t\t\treturn error;\n\t}\n\tif (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {\n\t\tif (vp->v_mount->mnt_flag & MNT_RDONLY)\n\t\t\treturn (EROFS);\n\t\tif (cred->cr_uid != pmp->pm_uid &&\n\t\t (error = priv_check_cred(cred, PRIV_VFS_SETATTR, 0)) &&\n\t\t ((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||\n\t\t (error = VOP_EACCESS(vp, VWRITE, cred))))\n\t\t\treturn (error);\n\t\tif (vp->v_type != VDIR) {\n\t\t\tif ((pmp->pm_flags & MSDOSFSMNT_NOWIN95) == 0 &&\n\t\t\t vap->va_atime.tv_sec != VNOVAL) {\n\t\t\t\tdep->de_flag &= ~DE_ACCESS;\n\t\t\t\ttimespec2fattime(&vap->va_atime, 0,\n\t\t\t\t &dep->de_ADate, NULL, NULL);\n\t\t\t}\n\t\t\tif (vap->va_mtime.tv_sec != VNOVAL) {\n\t\t\t\tdep->de_flag &= ~DE_UPDATE;\n\t\t\t\ttimespec2fattime(&vap->va_mtime, 0,\n\t\t\t\t &dep->de_MDate, &dep->de_MTime, NULL);\n\t\t\t}\n\t\t\tdep->de_Attributes |= ATTR_ARCHIVE;\n\t\t\tdep->de_flag |= DE_MODIFIED;\n\t\t}\n\t}\n\t\/*\n\t * DOS files only have the ability to have their writability\n\t * attribute set, so we use the owner write bit to set the readonly\n\t * attribute.\n\t *\/\n\tif (vap->va_mode != (mode_t)VNOVAL) {\n\t\tif (vp->v_mount->mnt_flag & MNT_RDONLY)\n\t\t\treturn (EROFS);\n\t\tif (cred->cr_uid != pmp->pm_uid &&\n\t\t (error = priv_check_cred(cred, PRIV_VFS_SETATTR, 0)))\n\t\t\treturn (error);\n\t\tif (vp->v_type != VDIR) {\n\t\t\t\/* We ignore the read and execute bits. *\/\n\t\t\tif (vap->va_mode & VWRITE)\n\t\t\t\tdep->de_Attributes &= ~ATTR_READONLY;\n\t\t\telse\n\t\t\t\tdep->de_Attributes |= ATTR_READONLY;\n\t\t\tdep->de_Attributes |= ATTR_ARCHIVE;\n\t\t\tdep->de_flag |= DE_MODIFIED;\n\t\t}\n\t}\n\treturn (deupdat(dep, 0));\n}\n\nstatic int\nmsdosfs_read(struct vop_read_args *ap)\n{\n\tint error = 0;\n\tint blsize;\n\tint isadir;\n\tsize_t orig_resid;\n\tu_int n;\n\tu_long diff;\n\tu_long on;\n\tu_long cn;\n\tdaddr_t lbn;\n\tdaddr_t rablock;\n\toff_t loffset;\n\tint rasize;\n\tint seqcount;\n\tstruct buf *bp;\n\tstruct vnode *vp = ap->a_vp;\n\tstruct denode *dep = VTODE(vp);\n\tstruct msdosfsmount *pmp = dep->de_pmp;\n\tstruct uio *uio = ap->a_uio;\n\n\tif (uio->uio_offset < 0)\n\t\treturn (EINVAL);\n\n\tif ((uoff_t)uio->uio_offset > MSDOSFS_FILESIZE_MAX)\n\t\treturn (0);\n\t\/*\n\t * If they didn't ask for any data, then we are done.\n\t *\/\n\torig_resid = uio->uio_resid;\n\tif (orig_resid == 0)\n\t\treturn (0);\n\n\t\/*\n\t * The caller is supposed to ensure that\n\t * uio->uio_offset >= 0 and uio->uio_resid >= 0.\n\t * We don't need to check for large offsets as in ffs because\n\t * dep->de_FileSize <= MSDOSFS_FILESIZE_MAX < OFF_MAX, so large\n\t * offsets cannot cause overflow even in theory.\n\t *\/\n\n\tseqcount = ap->a_ioflag >> IO_SEQSHIFT;\n\n\tisadir = dep->de_Attributes & ATTR_DIRECTORY;\n\tdo {\n\t\tif (uio->uio_offset >= dep->de_FileSize)\n\t\t\tbreak;\n\n\t\tcn = de_cluster(pmp, uio->uio_offset);\n\t\tloffset = de_cn2doff(pmp, cn);\n\t\trablock = cn + 1;\n\t\tblsize = pmp->pm_bpcluster;\n\t\ton = uio->uio_offset & pmp->pm_crbomask;\n\n\t\t\/*\n\t\t * If we are operating on a directory file then be sure to\n\t\t * do i\/o with the vnode for the filesystem instead of the\n\t\t * vnode for the directory.\n\t\t *\/\n\t\tbp = NULL;\n\t\tif (isadir) {\n\t\t\t\/* convert cluster # to block # *\/\n\t\t\terror = pcbmap(dep, cn, &lbn, NULL, &blsize);\n\t\t\tloffset = de_bn2doff(pmp, lbn);\n\t\t\tif (error == E2BIG) {\n\t\t\t\terror = EINVAL;\n\t\t\t\tbreak;\n\t\t\t} else if (error)\n\t\t\t\tbreak;\n\t\t\terror = bread(pmp->pm_devvp, loffset, blsize, &bp);\n\t\t} else if (de_cn2off(pmp, rablock) >= dep->de_FileSize) {\n\t\t\terror = bread(vp, loffset, blsize, &bp);\n\t\t} else if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {\n\t\t\terror = cluster_readx(vp,\n\t\t\t ((dep->de_FileSize + blsize - 1) \/ blsize) * blsize,\n\t\t\t loffset, blsize, B_NOTMETA, on + uio->uio_resid,\n\t\t\t seqcount * MAXBSIZE, &bp);\n\t\t\tbp->b_flags |= B_CLUSTEROK;\n\t\t} else if (seqcount > 1) {\n\t\t\toff_t raoffset = de_cn2doff(pmp, rablock);\n\t\t\trasize = blsize;\n\t\t\terror = breadn(vp, loffset,\n\t\t\t blsize, &raoffset, &rasize, 1, &bp);\n\t\t} else {\n\t\t\terror = bread(vp, loffset, blsize, &bp);\n\t\t}\n\t\tif (error) {\n\t\t\tbrelse(bp);\n\t\t\tbreak;\n\t\t}\n\t\tdiff = pmp->pm_bpcluster - on;\n\t\tn = szmin(uio->uio_resid, diff);\n\t\tdiff = dep->de_FileSize - uio->uio_offset;\n\t\tif (diff < n)\n\t\t\tn = diff;\n\t\tdiff = blsize - bp->b_resid;\n\t\tif (diff < n)\n\t\t\tn = diff;\n\t\terror = uiomovebp(bp, bp->b_data + on, (size_t)n, uio);\n\t\tbqrelse(bp);\n\t} while (error == 0 && uio->uio_resid > 0 && n != 0);\n\n\tif (!isadir && (error == 0 || uio->uio_resid != orig_resid) &&\n\t (vp->v_mount->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0)\n\t\tdep->de_flag |= DE_ACCESS;\n\treturn (error);\n}\n\n\/*\n * Write data to a file or directory.\n *\/\nstatic int\nmsdosfs_write(struct vop_write_args *ap)\n{\n\tint n;\n\tint croffset;\n\tsize_t resid;\n\tu_long osize;\n\tint error = 0;\n\tu_long count;\n\tint seqcount;\n\tdaddr_t cn, lastcn;\n\tstruct buf *bp = NULL;\n\tint ioflag = ap->a_ioflag;\n\tstruct uio *uio = ap->a_uio;\n\tstruct thread *td = uio->uio_td;\n\tstruct vnode *vp = ap->a_vp;\n\tstruct vnode *thisvp;\n\tstruct denode *dep = VTODE(vp);\n\tstruct msdosfsmount *pmp = dep->de_pmp;\n\tstruct proc *p = (td ? td->td_proc : NULL);\n\tstruct lwp *lp = (td ? td->td_lwp : NULL);\n\n\tmprintf(\"msdosfs_write(vp %p, uio %p, ioflag %x, cred %p\\n\",\n\t vp, uio, ioflag, ap->a_cred);\n\tmprintf(\"msdosfs_write(): diroff %lu, dirclust %lu, startcluster %lu\\n\",\n\t dep->de_diroffset, dep->de_dirclust, dep->de_StartCluster);\n\n\tswitch (vp->v_type) {\n\tcase VREG:\n\t\tif (ioflag & IO_APPEND)\n\t\t\tuio->uio_offset = dep->de_FileSize;\n\t\tthisvp = vp;\n\t\tbreak;\n\tcase VDIR:\n\t\treturn EISDIR;\n\tdefault:\n\t\tpanic(\"msdosfs_write(): bad file type\");\n\t}\n\n\tif (uio->uio_offset < 0)\n\t\treturn (EFBIG);\n\n\t\/*\n\t * This is needed (unlike in ffs_write()) because we extend the\n\t * file outside of the loop but we don't want to extend the file\n\t * for writes of 0 bytes.\n\t *\/\n\tif (uio->uio_resid == 0)\n\t\treturn (0);\n\n\t\/*\n\t * The caller is supposed to ensure that\n\t * uio->uio_offset >= 0 and uio->uio_resid >= 0.\n\t *\/\n\tif ((uoff_t)uio->uio_offset + uio->uio_resid > MSDOSFS_FILESIZE_MAX)\n\t\treturn (EFBIG);\n\n\t\/*\n\t * If they've exceeded their filesize limit, tell them about it.\n\t *\/\n\tif (p &&\n\t ((uoff_t)uio->uio_offset + uio->uio_resid >\n\t p->p_rlimit[RLIMIT_FSIZE].rlim_cur)) {\n\t\tlwpsignal(p, lp, SIGXFSZ);\n\t\treturn (EFBIG);\n\t}\n\n\t\/*\n\t * If the offset we are starting the write at is beyond the end of\n\t * the file, then they've done a seek. Unix filesystems allow\n\t * files with holes in them, DOS doesn't so we must fill the hole\n\t * with zeroed blocks.\n\t *\/\n\tif (uio->uio_offset > dep->de_FileSize) {\n\t\terror = deextend(dep, uio->uio_offset);\n\t\tif (error)\n\t\t\treturn (error);\n\t}\n\n\t\/*\n\t * Remember some values in case the write fails.\n\t *\/\n\tresid = uio->uio_resid;\n\tosize = dep->de_FileSize;\n\n\t\/*\n\t * If we write beyond the end of the file, extend it to its ultimate\n\t * size ahead of the time to hopefully get a contiguous area.\n\t *\/\n\tif (uio->uio_offset + resid > osize) {\n\t\tcount = de_clcount(pmp, uio->uio_offset + resid) -\n\t\t\tde_clcount(pmp, osize);\n\t\terror = extendfile(dep, count, NULL, NULL, 0);\n\t\tif (error && (error != ENOSPC || (ioflag & IO_UNIT)))\n\t\t\tgoto errexit;\n\t\tlastcn = dep->de_fc[FC_LASTFC].fc_frcn;\n\t} else\n\t\tlastcn = de_clcount(pmp, osize) - 1;\n\n\tseqcount = ioflag >> IO_SEQSHIFT;\n\tdo {\n\t\tif (de_cluster(pmp, uio->uio_offset) > lastcn) {\n\t\t\terror = ENOSPC;\n\t\t\tbreak;\n\t\t}\n\n\t\tcroffset = uio->uio_offset & pmp->pm_crbomask;\n\t\tn = (int)szmin(uio->uio_resid, pmp->pm_bpcluster - croffset);\n\t\tif (uio->uio_offset + n > dep->de_FileSize) {\n\t\t\tdep->de_FileSize = uio->uio_offset + n;\n\t\t\t\/* The object size needs to be set before buffer is allocated *\/\n\t\t\tvnode_pager_setsize(vp, dep->de_FileSize);\n\t\t}\n\n\t\t\/*\n\t\t * If either the whole cluster gets written, or we write\n\t\t * the cluster from its start beyond EOF, then no need to\n\t\t * read data from disk.\n\t\t *\n\t\t * If UIO_NOCOPY is set we have to do a read-before-write\n\t\t * to fill in any missing pieces of the buffer since no\n\t\t * actual overwrite will occur.\n\t\t *\/\n\t\tcn = de_cluster(pmp, uio->uio_offset);\n\t\tif ((uio->uio_offset & pmp->pm_crbomask) == 0\n\t\t && uio->uio_segflg != UIO_NOCOPY\n\t\t && (de_cluster(pmp, uio->uio_offset + uio->uio_resid)\n\t\t > de_cluster(pmp, uio->uio_offset)\n\t\t\t|| uio->uio_offset + uio->uio_resid >= dep->de_FileSize)) {\n\t\t\tbp = getblk(thisvp, de_cn2doff(pmp, cn),\n\t\t\t\t pmp->pm_bpcluster, 0, 0);\n\t\t\tclrbuf(bp);\n\t\t\t\/*\n\t\t\t * Do the bmap now, since pcbmap needs buffers\n\t\t\t * for the FAT table. (see msdosfs_strategy)\n\t\t\t *\/\n\t\t\tif (bp->b_bio2.bio_offset == NOOFFSET) {\n\t\t\t\tdaddr_t dblkno;\n\n\t\t\t\terror = pcbmap(dep,\n\t\t\t\t\t de_cluster(pmp, bp->b_loffset),\n\t\t\t\t\t &dblkno, NULL, NULL);\n\t\t\t\tif (error || dblkno == (daddr_t)-1) {\n\t\t\t\t\tbp->b_bio2.bio_offset = NOOFFSET;\n\t\t\t\t} else {\n\t\t\t\t\tbp->b_bio2.bio_offset = de_bn2doff(pmp,\n\t\t\t\t\t dblkno);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (bp->b_bio2.bio_offset == NOOFFSET) {\n\t\t\t\tbrelse(bp);\n\t\t\t\tif (!error)\n\t\t\t\t\terror = EIO;\t\t\/* XXX *\/\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\t\/*\n\t\t\t * The block we need to write into exists, so read\n\t\t\t * it in.\n\t\t\t *\/\n\t\t\terror = bread(thisvp, de_cn2doff(pmp, cn),\n\t\t\t\t pmp->pm_bpcluster, &bp);\n\t\t\tif (error) {\n\t\t\t\tbrelse(bp);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t\/*\n\t\t * Should these vnode_pager_* functions be done on dir\n\t\t * files?\n\t\t *\/\n\n\t\t\/*\n\t\t * Copy the data from user space into the buf header.\n\t\t *\/\n\t\terror = uiomovebp(bp, bp->b_data + croffset, (size_t)n, uio);\n\t\tif (error) {\n\t\t\tbrelse(bp);\n\t\t\tbreak;\n\t\t}\n\n\t\t\/* Prepare for clustered writes in some else clauses. *\/\n\t\tif ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0)\n\t\t\tbp->b_flags |= B_CLUSTEROK;\n\n\t\t\/*\n\t\t * If IO_SYNC, then each buffer is written synchronously.\n\t\t * Otherwise, if we have a severe page deficiency then\n\t\t * write the buffer asynchronously. Otherwise, if on a\n\t\t * cluster boundary then write the buffer asynchronously,\n\t\t * combining it with contiguous clusters if permitted and\n\t\t * possible, since we don't expect more writes into this\n\t\t * buffer soon. Otherwise, do a delayed write because we\n\t\t * expect more writes into this buffer soon.\n\t\t *\/\n\t\tif (ioflag & IO_SYNC)\n\t\t\tbwrite(bp);\n\t\telse if (vm_paging_severe() || buf_dirty_count_severe())\n\t\t\tbawrite(bp);\n\t\telse if (n + croffset == pmp->pm_bpcluster) {\n\t\t\tif ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0)\n\t\t\t\tcluster_write(bp, dep->de_FileSize,\n\t\t\t\t pmp->pm_bpcluster, seqcount);\n\t\t\telse\n\t\t\t\tbawrite(bp);\n\t\t} else\n\t\t\tbdwrite(bp);\n\t\tdep->de_flag |= DE_UPDATE;\n\t} while (error == 0 && uio->uio_resid > 0);\n\n\t\/*\n\t * If the write failed and they want us to, truncate the file back\n\t * to the size it was before the write was attempted.\n\t *\/\nerrexit:\n\tif (error) {\n\t\tif (ioflag & IO_UNIT) {\n\t\t\tdetrunc(dep, osize, ioflag & IO_SYNC);\n\t\t\tuio->uio_offset -= resid - uio->uio_resid;\n\t\t\tuio->uio_resid = resid;\n\t\t} else {\n\t\t\tdetrunc(dep, dep->de_FileSize, ioflag & IO_SYNC);\n\t\t\tif (uio->uio_resid != resid)\n\t\t\t\terror = 0;\n\t\t}\n\t} else if (ioflag & IO_SYNC)\n\t\terror = deupdat(dep, 1);\n\treturn (error);\n}\n\n\/*\n * Flush the blocks of a file to disk.\n *\/\nstatic int\nmsdosfs_fsync(struct vop_fsync_args *ap)\n{\n\tstruct vnode *vp = ap->a_vp;\n\tstruct vnode *devvp;\n\tint allerror, error;\n\n\t\/*\n\t * Flush all dirty buffers associated with a vnode.\n\t *\/\n#ifdef DIAGNOSTIC\nloop:\n#endif\n\tvfsync(vp, ap->a_waitfor, 0, NULL, NULL);\n#ifdef DIAGNOSTIC\n\tif (ap->a_waitfor == MNT_WAIT && !RB_EMPTY(&vp->v_rbdirty_tree)) {\n\t\tvprint(\"msdosfs_fsync: dirty\", vp);\n\t\tgoto loop;\n\t}\n#endif\n\t\/*\n\t* If the syncing request comes from fsync(2), sync the entire\n\t* FAT and any other metadata that happens to be on devvp. We\n\t* need this mainly for the FAT. We write the FAT sloppily, and\n\t* syncing it all now is the best we can easily do to get all\n\t* directory entries associated with the file (not just the file)\n\t* fully synced. The other metadata includes critical metadata\n\t* for all directory entries, but only in the MNT_ASYNC case. We\n\t* will soon sync all metadata in the file's directory entry.\n\t* Non-critical metadata for associated directory entries only\n\t* gets synced accidentally, as in most file systems.\n\t*\/\n\tif (ap->a_waitfor == MNT_WAIT) {\n\t\tdevvp = VTODE(ap->a_vp)->de_pmp->pm_devvp;\n\t\tvn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);\n\t\tallerror = VOP_FSYNC(devvp, MNT_WAIT, 0);\n\t\tvn_unlock(devvp);\n\t} else\n\t\tallerror = 0;\n\n\terror = deupdat(VTODE(ap->a_vp), ap->a_waitfor == MNT_WAIT);\n\tif (allerror == 0)\n\t\tallerror = error;\n\treturn (allerror);\n}\n\nstatic int\nmsdosfs_remove(struct vop_old_remove_args *ap)\n{\n\tstruct denode *dep = VTODE(ap->a_vp);\n\tstruct denode *ddep = VTODE(ap->a_dvp);\n\tint error;\n\n\tif (ap->a_vp->v_type == VDIR)\n\t\terror = EPERM;\n\telse\n\t\terror = removede(ddep, dep);\n\tmprintf(\"msdosfs_remove(), dep %p, v_refcnt 0x%08x\\n\",\n\t\tdep, ap->a_vp->v_refcnt);\n\treturn (error);\n}\n\n\/*\n * DOS filesystems don't know what links are.\n *\/\nstatic int\nmsdosfs_link(struct vop_old_link_args *ap)\n{\n\treturn (EOPNOTSUPP);\n}\n\n\/*\n * Renames on files require moving the denode to a new hash queue since the\n * denode's location is used to compute which hash queue to put the file\n * in. Unless it is a rename in place. For example \"mv a b\".\n *\n * What follows is the basic algorithm:\n *\n * if (file move) {\n *\tif (dest file exists) {\n *\t\tremove dest file\n *\t}\n *\tif (dest and src in same directory) {\n *\t\trewrite name in existing directory slot\n *\t} else {\n *\t\twrite new entry in dest directory\n *\t\tupdate offset and dirclust in denode\n *\t\tmove denode to new hash chain\n *\t\tclear old directory entry\n *\t}\n * } else {\n *\tdirectory move\n *\tif (dest directory exists) {\n *\t\tif (dest is not empty) {\n *\t\t\treturn ENOTEMPTY\n *\t\t}\n *\t\tremove dest directory\n *\t}\n *\tif (dest and src in same directory) {\n *\t\trewrite name in existing entry\n *\t} else {\n *\t\tbe sure dest is not a child of src directory\n *\t\twrite entry in dest directory\n *\t\tupdate \".\" and \"..\" in moved directory\n *\t\tclear old directory entry for moved directory\n *\t}\n * }\n *\n * On entry:\n *\tsource's parent directory is unlocked\n *\tsource file or directory is unlocked\n *\tdestination's parent directory is locked\n *\tdestination file or directory is locked if it exists\n *\n * On exit:\n *\tall denodes should be released\n *\/\nstatic int\nmsdosfs_rename(struct vop_old_rename_args *ap)\n{\n\tstruct vnode *tdvp = ap->a_tdvp;\n\tstruct vnode *fvp = ap->a_fvp;\n\tstruct vnode *fdvp = ap->a_fdvp;\n\tstruct vnode *tvp = ap->a_tvp;\n\tstruct componentname *tcnp = ap->a_tcnp;\n\tstruct componentname *fcnp = ap->a_fcnp;\n\tstruct denode *ip, *xp, *dp, *zp;\n\tu_char toname[12], oldname[11];\n\tu_long from_diroffset, to_diroffset;\n\tu_char to_count;\n\tint doingdirectory = 0, newparent = 0;\n\tint error;\n\tu_long cn, pcl;\n\tdaddr_t bn;\n\tstruct msdosfsmount *pmp;\n\tstruct direntry *dotdotp;\n\tstruct buf *bp = NULL;\n\n\tpmp = VFSTOMSDOSFS(fdvp->v_mount);\n\n\t\/*\n\t * Check for cross-device rename.\n\t *\/\n\tif (fvp->v_mount != tdvp->v_mount ||\n\t (tvp && fvp->v_mount != tvp->v_mount)) {\n\t\terror = EXDEV;\nabortit:\n\t\tif (tdvp == tvp)\n\t\t\tvrele(tdvp);\n\t\telse\n\t\t\tvput(tdvp);\n\t\tif (tvp)\n\t\t\tvput(tvp);\n\t\tvrele(fdvp);\n\t\tvrele(fvp);\n\t\treturn (error);\n\t}\n\n\t\/*\n\t * If source and dest are the same, do nothing.\n\t *\/\n\tif (tvp == fvp) {\n\t\terror = 0;\n\t\tgoto abortit;\n\t}\n\n\t\/*\n\t * fvp is unlocked, fdvp, tvp, tdvp are locked. Lock fvp and note\n\t * that we have to unlock it to use the abortit target.\n\t *\/\n\terror = vn_lock(fvp, LK_EXCLUSIVE | LK_FAILRECLAIM);\n\tif (error)\n\t\tgoto abortit;\n\tdp = VTODE(fdvp);\n\tip = VTODE(fvp);\n\n\t\/*\n\t * Be sure we are not renaming \".\", \"..\", or an alias of \".\". This\n\t * leads to a crippled directory tree. It's pretty tough to do a\n\t * \"ls\" or \"pwd\" with the \".\" directory entry missing, and \"cd ..\"\n\t * doesn't work if the \"..\" entry is missing.\n\t *\/\n\tif (ip->de_Attributes & ATTR_DIRECTORY) {\n\t\t\/*\n\t\t * Avoid \".\", \"..\", and aliases of \".\" for obvious reasons.\n\t\t *\/\n\t\tif ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') ||\n\t\t dp == ip ||\n\t\t (fcnp->cn_flags & CNP_ISDOTDOT) ||\n\t\t (tcnp->cn_flags & CNP_ISDOTDOT) ||\n\t\t (ip->de_flag & DE_RENAME)) {\n\t\t\tvn_unlock(fvp);\n\t\t\terror = EINVAL;\n\t\t\tgoto abortit;\n\t\t}\n\t\tip->de_flag |= DE_RENAME;\n\t\tdoingdirectory++;\n\t}\n\n\t\/*\n\t * fvp locked, fdvp unlocked, tvp, tdvp locked. DE_RENAME only\n\t * set if doingdirectory. We will get fvp unlocked in fairly\n\t * short order. dp and xp must be setup and fvp must be unlocked\n\t * for the out and bad targets to work properly.\n\t *\/\n\tdp = VTODE(tdvp);\n\txp = tvp ? VTODE(tvp) : NULL;\n\n\t\/*\n\t * Remember direntry place to use for destination\n\t *\/\n\tto_diroffset = dp->de_fndoffset;\n\tto_count = dp->de_fndcnt;\n\n\t\/*\n\t * If \"..\" must be changed (ie the directory gets a new\n\t * parent) then the source directory must not be in the\n\t * directory hierarchy above the target, as this would\n\t * orphan everything below the source directory. Also\n\t * the user must have write permission in the source so\n\t * as to be able to change \"..\". We must repeat the call\n\t * to namei, as the parent directory is unlocked by the\n\t * call to doscheckpath().\n\t *\/\n\terror = VOP_EACCESS(fvp, VWRITE, tcnp->cn_cred);\n\tvn_unlock(fvp);\n\tif (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster)\n\t\tnewparent = 1;\n\n\t\/*\n\t * ok. fvp, fdvp unlocked, tvp, tdvp locked. tvp may be NULL.\n\t * DE_RENAME only set if doingdirectory.\n\t *\/\n\tif (doingdirectory && newparent) {\n\t\tif (error)\t\/* write access check above *\/\n\t\t\tgoto bad;\n\t\tif (xp != NULL) {\n\t\t\tvput(tvp);\n\t\t\txp = NULL;\n\t\t}\n\t\t\/*\n\t\t * checkpath vput's tdvp (VTOI(dp)) on return no matter what,\n\t\t * get an extra ref so we wind up with just an unlocked, ref'd\n\t\t * tdvp. The 'out' target skips tvp and tdvp cleanups (tdvp\n\t\t * isn't locked so we can't use the out target).\n\t\t *\/\n\t\tvref(tdvp);\n\t\terror = doscheckpath(ip, dp);\n\t\ttcnp->cn_flags |= CNP_PDIRUNLOCK;\n\t\tif (error) {\n\t\t\tvrele(tdvp);\n\t\t\tgoto out;\n\t\t}\n\t\t\/*\n\t\t * relookup no longer messes with the ref count. tdvp must\n\t\t * be unlocked on entry and on success will be locked on\n\t\t * return.\n\t\t *\/\n\t\terror = relookup(tdvp, &tvp, tcnp);\n\t\tif (error) {\n\t\t\tif (tcnp->cn_flags & CNP_PDIRUNLOCK)\n\t\t\t\tvrele(tdvp);\n\t\t\telse\n\t\t\t\tvput(tdvp);\n\t\t\tgoto out;\n\t\t}\n\n\t\t\/*\n\t\t * tvp and tdvp are now locked again.\n\t\t *\/\n\t\tdp = VTODE(tdvp);\n\t\txp = tvp ? VTODE(tvp) : NULL;\n\t}\n\n\t\/*\n\t * tvp and tdvp are now locked again, the 'bad' target can be used\n\t * to clean them up again. Delete an existant target and clean\n\t * up tvp. Set xp to NULL to indicate that tvp has been cleaned up.\n\t *\/\n\tif (xp != NULL) {\n\t\t\/*\n\t\t * Target must be empty if a directory and have no links\n\t\t * to it. Also, ensure source and target are compatible\n\t\t * (both directories, or both not directories).\n\t\t *\/\n\t\tif (xp->de_Attributes & ATTR_DIRECTORY) {\n\t\t\tif (!dosdirempty(xp)) {\n\t\t\t\terror = ENOTEMPTY;\n\t\t\t\tgoto bad;\n\t\t\t}\n\t\t\tif (!doingdirectory) {\n\t\t\t\terror = ENOTDIR;\n\t\t\t\tgoto bad;\n\t\t\t}\n\t\t} else if (doingdirectory) {\n\t\t\terror = EISDIR;\n\t\t\tgoto bad;\n\t\t}\n\t\terror = removede(dp, xp);\n\t\tif (error)\n\t\t\tgoto bad;\n\t\tvput(tvp);\n\t\txp = NULL;\n\t\ttvp = NULL;\n\t}\n\n\t\/*\n\t * Convert the filename in tcnp into a dos filename. We copy this\n\t * into the denode and directory entry for the destination\n\t * file\/directory.\n\t *\/\n\terror = uniqdosname(VTODE(tdvp), tcnp, toname);\n\tif (error)\n\t\tgoto bad;\n\n\t\/*\n\t * Since from wasn't locked at various places above, we have to do\n\t * a relookup here. If the target and source are the same directory\n\t * we have to unlock the target directory in order to safely relookup\n\t * the source, because relookup expects its directory to be unlocked.\n\t *\n\t * Note that ap->a_fvp is still valid and ref'd. Any cleanup must\n\t * now take that into account.\n\t *\n\t * The tdvp locking issues make this a real mess.\n\t *\/\n\tfcnp->cn_flags &= ~CNP_MODMASK;\n\tfcnp->cn_flags |= CNP_LOCKPARENT;\n\tif (newparent == 0)\n\t\tvn_unlock(tdvp);\n\terror = relookup(fdvp, &fvp, fcnp);\n\tif (error || fvp == NULL) {\n\t\t\/*\n\t\t * From name has disappeared. Note: fdvp might == tdvp.\n\t\t *\n\t\t * DE_RENAME is only set if doingdirectory.\n\t\t *\/\n\t\tif (doingdirectory)\n\t\t\tpanic(\"rename: lost dir entry\");\n\t\tif (fcnp->cn_flags & CNP_PDIRUNLOCK)\n\t\t\tvrele(fdvp);\n\t\telse\n\t\t\tvput(fdvp);\n\t\tif (newparent == 0)\n\t\t\tvrele(tdvp);\n\t\telse\n\t\t\tvput(tdvp);\n\t\tvrele(ap->a_fvp);\n\t\treturn(0);\n\t}\n\n\t\/*\n\t * No error occured. tdvp, fdvp and fvp are all locked. If\n\t * newparent was 0 be aware that fdvp == tdvp. tvp has been cleaned\n\t * up. ap->a_fvp is still refd.\n\t *\/\n\txp = VTODE(fvp);\n\tzp = VTODE(fdvp);\n\tfrom_diroffset = zp->de_fndoffset;\n\n\t\/*\n\t * Ensure that the directory entry still exists and has not\n\t * changed till now. If the source is a file the entry may\n\t * have been unlinked or renamed. In either case there is\n\t * no further work to be done. If the source is a directory\n\t * then it cannot have been rmdir'ed or renamed; this is\n\t * prohibited by the DE_RENAME flag.\n\t *\n\t * DE_RENAME is only set if doingdirectory.\n\t *\/\n\tif (xp != ip) {\n\t\tif (doingdirectory)\n\t\t\tpanic(\"rename: lost dir entry\");\n\t\tgoto done;\n\t} else {\n\t\tu_long new_dirclust;\n\t\tu_long new_diroffset;\n\n\t\t\/*\n\t\t * First write a new entry in the destination\n\t\t * directory and mark the entry in the source directory\n\t\t * as deleted. Then move the denode to the correct hash\n\t\t * chain for its new location in the filesystem. And, if\n\t\t * we moved a directory, then update its .. entry to point\n\t\t * to the new parent directory.\n\t\t *\/\n\t\tmemcpy(oldname, ip->de_Name, 11);\n\t\tmemcpy(ip->de_Name, toname, 11);\t\/* update denode *\/\n\t\tdp->de_fndoffset = to_diroffset;\n\t\tdp->de_fndcnt = to_count;\n\t\terror = createde(ip, dp, NULL, tcnp);\n\t\tif (error) {\n\t\t\tmemcpy(ip->de_Name, oldname, 11);\n\t\t\tgoto done;\n\t\t}\n\t\t\/*\n\t\t * If ip is for a directory, then its name should always\n\t\t * be \".\" since it is for the directory entry in the\n\t\t * directory itself (msdosfs_lookup() always translates\n\t\t * to the \".\" entry so as to get a unique denode, except\n\t\t * for the root directory there are different\n\t\t * complications). However, we just corrupted its name\n\t\t * to pass the correct name to createde(). Undo this.\n\t\t *\/\n\t\tif ((ip->de_Attributes & ATTR_DIRECTORY) != 0)\n\t\t\tmemcpy(ip->de_Name, oldname, 11);\n\t\tip->de_refcnt++;\n\t\tzp->de_fndoffset = from_diroffset;\n\t\terror = removede(zp, ip);\n\t\tif (error) {\n\t\t\t\/* XXX should downgrade to ro here, fs is corrupt *\/\n\t\t\tgoto done;\n\t\t}\n\t\tif (!doingdirectory) {\n\t\t\terror = pcbmap(dp, de_cluster(pmp, to_diroffset),\n\t\t\t\t NULL, &new_dirclust, NULL);\n\t\t\tif (error) {\n\t\t\t\t\/* XXX should downgrade to ro here, fs is corrupt *\/\n\t\t\t\tgoto done;\n\t\t\t}\n\t\t\tif (new_dirclust == MSDOSFSROOT)\n\t\t\t\tnew_diroffset = to_diroffset;\n\t\t\telse\n\t\t\t\tnew_diroffset = to_diroffset & pmp->pm_crbomask;\n\t\t\tmsdosfs_reinsert(ip, new_dirclust, new_diroffset);\n\t\t}\n\t}\n\n\t\/*\n\t * If we moved a directory to a new parent directory, then we must\n\t * fixup the \"..\" entry in the moved directory.\n\t *\/\n\tif (doingdirectory && newparent) {\n\t\tcn = ip->de_StartCluster;\n\t\tif (cn == MSDOSFSROOT) {\n\t\t\t\/* this should never happen *\/\n\t\t\tpanic(\"msdosfs_rename(): updating .. in root directory?\");\n\t\t} else {\n\t\t\tbn = cntobn(pmp, cn);\n\t\t}\n\t\terror = bread(pmp->pm_devvp, de_bn2doff(pmp, bn),\n\t\t\t pmp->pm_bpcluster, &bp);\n\t\tif (error) {\n\t\t\t\/* XXX should downgrade to ro here, fs is corrupt *\/\n\t\t\tbrelse(bp);\n\t\t\tgoto done;\n\t\t}\n\t\tdotdotp = (struct direntry *)bp->b_data + 1;\n\t\tpcl = dp->de_StartCluster;\n\t\tif (FAT32(pmp) && pcl == pmp->pm_rootdirblk)\n\t\t\tpcl = MSDOSFSROOT;\n\t\tputushort(dotdotp->deStartCluster, pcl);\n\t\tif (FAT32(pmp))\n\t\t\tputushort(dotdotp->deHighClust, pcl >> 16);\n\t\tif (DOINGASYNC(fvp))\n\t\t\tbdwrite(bp);\n\t\telse if ((error = bwrite(bp)) != 0) {\n\t\t\t\/* XXX should downgrade to ro here, fs is corrupt *\/\n\t\t\tgoto done;\n\t\t}\n\t}\n\n\t\/*\n\t * done case fvp, fdvp, tdvp are locked. ap->a_fvp is refd\n\t *\/\ndone:\n\tif (doingdirectory)\n\t\tip->de_flag &= ~DE_RENAME;\t\/* XXX fvp not locked *\/\n\tvput(fvp);\n\tif (newparent)\n\t\tvput(fdvp);\n\telse\n\t\tvrele(fdvp);\n\tvput(tdvp);\n\tvrele(ap->a_fvp);\n\treturn (error);\n\n\t\/*\n\t * 'bad' target: xp governs tvp. tvp and tdvp are locked, fdvp and fvp\n\t * are not locked. ip points to fvp's inode which may have DE_RENAME\n\t * set.\n\t *\/\nbad:\n\tif (xp)\n\t\tvput(tvp);\n\tvput(tdvp);\nout:\n\t\/*\n\t * 'out' target: tvp and tdvp have already been cleaned up.\n\t *\/\n\tif (doingdirectory)\n\t\tip->de_flag &= ~DE_RENAME;\n\tvrele(fdvp);\n\tvrele(fvp);\n\treturn (error);\n\n}\n\nstatic struct {\n\tstruct direntry dot;\n\tstruct direntry dotdot;\n} dosdirtemplate = {\n\t{\t\". \",\t\t\t\t\/* the . entry *\/\n\t\tATTR_DIRECTORY,\t\t\t\t\/* file attribute *\/\n\t\t0,\t\t\t\t\t\/* reserved *\/\n\t\t0, { 0, 0 }, { 0, 0 },\t\t\t\/* create time & date *\/\n\t\t{ 0, 0 },\t\t\t\t\/* access date *\/\n\t\t{ 0, 0 },\t\t\t\t\/* high bits of start cluster *\/\n\t\t{ 210, 4 }, { 210, 4 },\t\t\t\/* modify time & date *\/\n\t\t{ 0, 0 },\t\t\t\t\/* startcluster *\/\n\t\t{ 0, 0, 0, 0 }\t\t\t\t\/* filesize *\/\n\t},\n\t{\t\".. \",\t\t\t\t\/* the .. entry *\/\n\t\tATTR_DIRECTORY,\t\t\t\t\/* file attribute *\/\n\t\t0,\t\t\t\t\t\/* reserved *\/\n\t\t0, { 0, 0 }, { 0, 0 },\t\t\t\/* create time & date *\/\n\t\t{ 0, 0 },\t\t\t\t\/* access date *\/\n\t\t{ 0, 0 },\t\t\t\t\/* high bits of start cluster *\/\n\t\t{ 210, 4 }, { 210, 4 },\t\t\t\/* modify time & date *\/\n\t\t{ 0, 0 },\t\t\t\t\/* startcluster *\/\n\t\t{ 0, 0, 0, 0 }\t\t\t\t\/* filesize *\/\n\t}\n};\n\nstatic int\nmsdosfs_mkdir(struct vop_old_mkdir_args *ap)\n{\n\tstruct componentname *cnp = ap->a_cnp;\n\tstruct denode *dep;\n\tstruct denode *pdep = VTODE(ap->a_dvp);\n\tstruct direntry *denp;\n\tstruct msdosfsmount *pmp = pdep->de_pmp;\n\tstruct buf *bp;\n\tu_long newcluster, pcl;\n\tint bn;\n\tint error;\n\tstruct denode ndirent;\n\tstruct timespec ts;\n\n\t\/*\n\t * If this is the root directory and there is no space left we\n\t * can't do anything. This is because the root directory can not\n\t * change size.\n\t *\/\n\tif (pdep->de_StartCluster == MSDOSFSROOT\n\t && pdep->de_fndoffset >= pdep->de_FileSize) {\n\t\terror = ENOSPC;\n\t\tgoto bad2;\n\t}\n\n\t\/*\n\t * Allocate a cluster to hold the about to be created directory.\n\t *\/\n\terror = clusteralloc(pmp, 0, 1, CLUST_EOFE, &newcluster, NULL);\n\tif (error)\n\t\tgoto bad2;\n\n\tmemset(&ndirent, 0, sizeof(ndirent));\n\tndirent.de_pmp = pmp;\n\tndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;\n\tvfs_timestamp(&ts);\n\tDETIMES(&ndirent, &ts, &ts, &ts);\n\n\t\/*\n\t * Now fill the cluster with the \".\" and \"..\" entries. And write\n\t * the cluster to disk. This way it is there for the parent\n\t * directory to be pointing at if there were a crash.\n\t *\/\n\tbn = cntobn(pmp, newcluster);\n\t\/* always succeeds *\/\n\tbp = getblk(pmp->pm_devvp, de_bn2doff(pmp, bn),\n\t\t pmp->pm_bpcluster, 0, 0);\n\tmemset(bp->b_data, 0, pmp->pm_bpcluster);\n\tmemcpy(bp->b_data, &dosdirtemplate, sizeof(dosdirtemplate));\n\tdenp = (struct direntry *)bp->b_data;\n\tputushort(denp[0].deStartCluster, newcluster);\n\tputushort(denp[0].deCDate, ndirent.de_CDate);\n\tputushort(denp[0].deCTime, ndirent.de_CTime);\n\tdenp[0].deCHundredth = ndirent.de_CHun;\n\tputushort(denp[0].deADate, ndirent.de_ADate);\n\tputushort(denp[0].deMDate, ndirent.de_MDate);\n\tputushort(denp[0].deMTime, ndirent.de_MTime);\n\tpcl = pdep->de_StartCluster;\n\t\/*\n\t * Although the root directory has a non-magic starting cluster\n\t * number for FAT32, chkdsk and fsck_msdosfs still require\n\t * references to it in dotdot entries to be magic.\n\t *\/\n\tif (FAT32(pmp) && pcl == pmp->pm_rootdirblk)\n\t\tpcl = MSDOSFSROOT;\n\tputushort(denp[1].deStartCluster, pcl);\n\tputushort(denp[1].deCDate, ndirent.de_CDate);\n\tputushort(denp[1].deCTime, ndirent.de_CTime);\n\tdenp[1].deCHundredth = ndirent.de_CHun;\n\tputushort(denp[1].deADate, ndirent.de_ADate);\n\tputushort(denp[1].deMDate, ndirent.de_MDate);\n\tputushort(denp[1].deMTime, ndirent.de_MTime);\n\tif (FAT32(pmp)) {\n\t\tputushort(denp[0].deHighClust, newcluster >> 16);\n\t\tputushort(denp[1].deHighClust, pcl >> 16);\n\t}\n\n\tif (DOINGASYNC(ap->a_dvp))\n\t\tbdwrite(bp);\n\telse if ((error = bwrite(bp)) != 0)\n\t\tgoto bad;\n\n\t\/*\n\t * Now build up a directory entry pointing to the newly allocated\n\t * cluster. This will be written to an empty slot in the parent\n\t * directory.\n\t *\/\n\terror = uniqdosname(pdep, cnp, ndirent.de_Name);\n\tif (error)\n\t\tgoto bad;\n\n\tndirent.de_Attributes = ATTR_DIRECTORY;\n\tndirent.de_LowerCase = 0;\n\tndirent.de_StartCluster = newcluster;\n\tndirent.de_FileSize = 0;\n\tndirent.de_dev = pdep->de_dev;\n\tndirent.de_devvp = pdep->de_devvp;\n\terror = createde(&ndirent, pdep, &dep, cnp);\n\tif (error)\n\t\tgoto bad;\n\t*ap->a_vpp = DETOV(dep);\n\treturn (0);\n\nbad:\n\tclusterfree(pmp, newcluster);\nbad2:\n\treturn (error);\n}\n\nstatic int\nmsdosfs_rmdir(struct vop_old_rmdir_args *ap)\n{\n\tstruct vnode *vp = ap->a_vp;\n\tstruct vnode *dvp = ap->a_dvp;\n\tstruct denode *ip, *dp;\n\tint error;\n\n\tip = VTODE(vp);\n\tdp = VTODE(dvp);\n\n\t\/*\n\t * Verify the directory is empty (and valid).\n\t * (Rmdir \"..\" won't be valid since\n\t * \"..\" will contain a reference to\n\t * the current directory and thus be\n\t * non-empty.)\n\t *\/\n\terror = 0;\n\tif (!dosdirempty(ip) || ip->de_flag & DE_RENAME) {\n\t\terror = ENOTEMPTY;\n\t\tgoto out;\n\t}\n\t\/*\n\t * Delete the entry from the directory. For dos filesystems this\n\t * gets rid of the directory entry on disk, the in memory copy\n\t * still exists but the de_refcnt is <= 0. This prevents it from\n\t * being found by deget(). When the vput() on dep is done we give\n\t * up access and eventually msdosfs_reclaim() will be called which\n\t * will remove it from the denode cache.\n\t *\/\n\terror = removede(dp, ip);\n\tif (error)\n\t\tgoto out;\n\t\/*\n\t * Truncate the directory that is being deleted.\n\t *\/\n\terror = detrunc(ip, (u_long)0, IO_SYNC);\nout:\n\treturn (error);\n}\n\n\/*\n * DOS filesystems don't know what symlinks are.\n *\/\nstatic int\nmsdosfs_symlink(struct vop_old_symlink_args *ap)\n{\n\treturn (EOPNOTSUPP);\n}\n\nstatic int\nmsdosfs_readdir(struct vop_readdir_args *ap)\n{\n\tstruct mbnambuf nb;\n\tint error = 0;\n\tint diff;\n\tlong n;\n\tint blsize;\n\tlong on;\n\tu_long cn;\n\tu_long dirsperblk;\n\tlong bias = 0;\n\tdaddr_t bn, lbn;\n\tstruct buf *bp = NULL;\n\tstruct denode *dep;\n\tstruct msdosfsmount *pmp;\n\tstruct direntry *dentp;\n\tstruct dirent dirbuf;\n\tstruct uio *uio = ap->a_uio;\n\toff_t *cookies = NULL;\n\tint ncookies = 0;\n\toff_t offset, off;\n\tint chksum = -1;\n\n\terror = vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM);\n\tif (error)\n\t\treturn (error);\n\n\tdep = VTODE(ap->a_vp);\n\tpmp = dep->de_pmp;\n\n\tmprintf(\"msdosfs_readdir(): vp %p, uio %p, cred %p, eofflagp %p\\n\",\n\t ap->a_vp, uio, ap->a_cred, ap->a_eofflag);\n\n\t\/*\n\t * msdosfs_readdir() won't operate properly on regular files since\n\t * it does i\/o only with the filesystem vnode, and hence can\n\t * retrieve the wrong block from the buffer cache for a plain file.\n\t * So, fail attempts to readdir() on a plain file.\n\t *\/\n\tif ((dep->de_Attributes & ATTR_DIRECTORY) == 0) {\n\t\terror = ENOTDIR;\n\t\tgoto done;\n\t}\n\n\t\/*\n\t * To be safe, initialize dirbuf\n\t *\/\n\tmemset(dirbuf.d_name, 0, sizeof(dirbuf.d_name));\n\n\t\/*\n\t * If the user buffer is smaller than the size of one dos directory\n\t * entry or the file offset is not a multiple of the size of a\n\t * directory entry, then we fail the read.\n\t *\/\n\toff = offset = uio->uio_offset;\n\tif (uio->uio_resid < sizeof(struct direntry) ||\n\t (offset & (sizeof(struct direntry) - 1))) {\n\t\terror = EINVAL;\n\t\tgoto done;\n\t}\n\n\tif (ap->a_ncookies) {\n\t\tncookies = uio->uio_resid \/ 16 + 1;\n\t\tif (ncookies > 1024)\n\t\t\tncookies = 1024;\n\t\tcookies = kmalloc(ncookies * sizeof(off_t), M_TEMP, M_WAITOK);\n\t\t*ap->a_cookies = cookies;\n\t\t*ap->a_ncookies = ncookies;\n\t}\n\n\tdirsperblk = pmp->pm_BytesPerSec \/ sizeof(struct direntry);\n\n#define d_fileno d_ino\n\t\/*\n\t * If they are reading from the root directory then, we simulate\n\t * the . and .. entries since these don't exist in the root\n\t * directory. We also set the offset bias to make up for having to\n\t * simulate these entries. By this I mean that at file offset 64 we\n\t * read the first entry in the root directory that lives on disk.\n\t *\/\n\tif (dep->de_StartCluster == MSDOSFSROOT\n\t || (FAT32(pmp) && dep->de_StartCluster == pmp->pm_rootdirblk)) {\n#if 0\n\t\tprintf(\"msdosfs_readdir(): going after . or .. in root dir, offset %d\\n\",\n\t\t offset);\n#endif\n\t\tbias = 2 * sizeof(struct direntry);\n\t\tif (offset < bias) {\n\t\t\tfor (n = (int)offset \/ sizeof(struct direntry);\n\t\t\t n < 2; n++) {\n\t\t\t\tdirbuf.d_fileno = FAT32(pmp) ?\n\t\t\t\t (uint64_t)cntobn(pmp, pmp->pm_rootdirblk) *\n\t\t\t\t dirsperblk : 1;\n\t\t\t\tdirbuf.d_type = DT_DIR;\n\t\t\t\tswitch (n) {\n\t\t\t\tcase 0:\n\t\t\t\t\tdirbuf.d_namlen = 1;\n\t\t\t\t\tdirbuf.d_name[0] = '.';\n\t\t\t\t\tbreak;\n\t\t\t\tcase 1:\n\t\t\t\t\tdirbuf.d_namlen = 2;\n\t\t\t\t\tdirbuf.d_name[0] = '.';\n\t\t\t\t\tdirbuf.d_name[1] = '.';\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (vop_write_dirent(&error, uio,\n\t\t\t\t dirbuf.d_fileno, dirbuf.d_type,\n\t\t\t\t dirbuf.d_namlen, dirbuf.d_name))\n\t\t\t\t\tgoto out;\n\t\t\t\tif (error)\n\t\t\t\t\tgoto out;\n\t\t\t\toffset += sizeof(struct direntry);\n\t\t\t\toff = offset;\n\t\t\t\tif (cookies) {\n\t\t\t\t\t*cookies++ = offset;\n\t\t\t\t\tif (--ncookies <= 0)\n\t\t\t\t\t\tgoto out;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tmbnambuf_init(&nb);\n\toff = offset;\n\n\twhile (uio->uio_resid > 0) {\n\t\tlbn = de_cluster(pmp, offset - bias);\n\t\ton = (offset - bias) & pmp->pm_crbomask;\n\t\tn = szmin(pmp->pm_bpcluster - on, uio->uio_resid);\n\t\tdiff = dep->de_FileSize - (offset - bias);\n\t\tif (diff <= 0)\n\t\t\tbreak;\n\t\tn = min(n, diff);\n\t\terror = pcbmap(dep, lbn, &bn, &cn, &blsize);\n\t\tif (error)\n\t\t\tbreak;\n\t\terror = bread(pmp->pm_devvp, de_bn2doff(pmp, bn), blsize, &bp);\n\t\tif (error) {\n\t\t\tbrelse(bp);\n\t\t\tgoto done;\n\t\t}\n\t\tn = min(n, blsize - bp->b_resid);\n\t\tif (n == 0) {\n\t\t\tbrelse(bp);\n\t\t\terror = EIO;\n\t\t\tgoto done;\n\t\t}\n\n\t\t\/*\n\t\t * Convert from dos directory entries to fs-independent\n\t\t * directory entries.\n\t\t *\/\n\t\tfor (dentp = (struct direntry *)(bp->b_data + on);\n\t\t (char *)dentp < bp->b_data + on + n;\n\t\t dentp++, offset += sizeof(struct direntry)) {\n#if 0\n\t\t\tprintf(\"rd: dentp %08x prev %08x crnt %08x deName %02x attr %02x\\n\",\n\t\t\t dentp, prev, crnt, dentp->deName[0], dentp->deAttributes);\n#endif\n\t\t\t\/*\n\t\t\t * If this is an unused entry, we can stop.\n\t\t\t *\/\n\t\t\tif (dentp->deName[0] == SLOT_EMPTY) {\n\t\t\t\tbrelse(bp);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\t\/*\n\t\t\t * Skip deleted entries.\n\t\t\t *\/\n\t\t\tif (dentp->deName[0] == SLOT_DELETED) {\n\t\t\t\tchksum = -1;\n\t\t\t\tmbnambuf_init(&nb);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * Handle Win95 long directory entries\n\t\t\t *\/\n\t\t\tif (dentp->deAttributes == ATTR_WIN95) {\n\t\t\t\tif (pmp->pm_flags & MSDOSFSMNT_SHORTNAME)\n\t\t\t\t\tcontinue;\n\t\t\t\tchksum = win2unixfn(&nb,\n\t\t\t\t (struct winentry *)dentp, chksum, pmp);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t\/*\n\t\t\t * Skip volume labels\n\t\t\t *\/\n\t\t\tif (dentp->deAttributes & ATTR_VOLUME) {\n\t\t\t\tchksum = -1;\n\t\t\t\tmbnambuf_init(&nb);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\/*\n\t\t\t * This computation of d_fileno must match\n\t\t\t * the computation of va_fileid in\n\t\t\t * msdosfs_getattr.\n\t\t\t *\/\n\t\t\tif (dentp->deAttributes & ATTR_DIRECTORY) {\n\t\t\t\tcn = getushort(dentp->deStartCluster);\n\t\t\t\tif (FAT32(pmp)) {\n\t\t\t\t\tcn |= getushort(dentp->deHighClust) <<\n\t\t\t\t\t 16;\n\t\t\t\t\tif (cn == MSDOSFSROOT)\n\t\t\t\t\t\tcn = pmp->pm_rootdirblk;\n\t\t\t\t}\n\t\t\t\tif (cn == MSDOSFSROOT && !FAT32(pmp))\n\t\t\t\t\tdirbuf.d_fileno = 1;\n\t\t\t\telse\n\t\t\t\t\tdirbuf.d_fileno = cntobn(pmp, cn) *\n\t\t\t\t\t dirsperblk;\n\t\t\t\tdirbuf.d_type = DT_DIR;\n\t\t\t} else {\n\t\t\t\tdirbuf.d_fileno = (uoff_t)offset \/\n\t\t\t\t sizeof(struct direntry);\n\t\t\t\tdirbuf.d_type = DT_REG;\n\t\t\t}\n\n\t\t\tif (chksum != winChksum(dentp->deName)) {\n\t\t\t\tdirbuf.d_namlen = dos2unixfn(dentp->deName,\n\t\t\t\t (u_char *)dirbuf.d_name,\n\t\t\t\t dentp->deLowerCase |\n\t\t\t\t\t((pmp->pm_flags & MSDOSFSMNT_SHORTNAME) ?\n\t\t\t\t\t(LCASE_BASE | LCASE_EXT) : 0),\n\t\t\t\t pmp);\n\t\t\t\tmbnambuf_init(&nb);\n\t\t\t} else\n\t\t\t\tmbnambuf_flush(&nb, &dirbuf);\n\t\t\tchksum = -1;\n\t\t\tif (vop_write_dirent(&error, uio, dirbuf.d_fileno,\n\t\t\t dirbuf.d_type, dirbuf.d_namlen, dirbuf.d_name)) {\n\t\t\t\tbrelse(bp);\n\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tif (error) {\n\t\t\t\tbrelse(bp);\n\t\t\t\tgoto out;\n\t\t\t}\n\n\t\t\tif (cookies) {\n\t\t\t\t*cookies++ = offset + sizeof(struct direntry);\n\t\t\t\tif (--ncookies <= 0) {\n\t\t\t\t\tbrelse(bp);\n\t\t\t\t\tgoto out;\n\t\t\t\t}\n\t\t\t}\n\t\t\toff = offset + sizeof(struct direntry);\n\t\t}\n\t\tbrelse(bp);\n\t}\nout:\n\t\/* Subtract unused cookies *\/\n\tif (ap->a_ncookies)\n\t\t*ap->a_ncookies -= ncookies;\n\n\tuio->uio_offset = off;\n\n\t\/*\n\t * Set the eofflag (NFS uses it)\n\t *\/\n\tif (ap->a_eofflag) {\n\t\tif (dep->de_FileSize - (offset - bias) <= 0)\n\t\t\t*ap->a_eofflag = 1;\n\t\telse\n\t\t\t*ap->a_eofflag = 0;\n\t}\ndone:\n\tvn_unlock(ap->a_vp);\n\treturn (error);\n}\n\n\/*-\n * a_vp - pointer to the file's vnode\n * a_runp - where to return the \"run past\" a_bn. This is the count of logical\n * blocks whose physical blocks (together with a_bn's physical block)\n * are contiguous.\n * a_runb - where to return the \"run before\" a_bn.\n *\/\nstatic int\nmsdosfs_bmap(struct vop_bmap_args *ap)\n{\n\tstruct fatcache savefc;\n\tstruct denode *dep;\n\tstruct mount *mp;\n\tstruct msdosfsmount *pmp;\n\tstruct vnode *vp;\n\tdaddr_t dbn, runbn;\n\tu_long cn;\n\tint bnpercn, error, maxio, maxrun, run;\n\n\tvp = ap->a_vp;\n\tdep = VTODE(vp);\n\tpmp = dep->de_pmp;\n\n\tif (ap->a_doffsetp == NULL)\n\t\treturn (0);\n\tif (ap->a_runp != NULL)\n\t\t*ap->a_runp = 0;\n\tif (ap->a_runb != NULL)\n\t\t*ap->a_runb = 0;\n\n\tKKASSERT(((int)ap->a_loffset & ((1 << pmp->pm_cnshift) - 1)) == 0);\n\terror = pcbmap(dep, de_cluster(pmp, ap->a_loffset), &dbn, NULL, NULL);\n\tif (error || dbn == (daddr_t)-1)\n\t\t*ap->a_doffsetp = NOOFFSET;\n\telse\n\t\t*ap->a_doffsetp = de_bn2doff(pmp, dbn);\n\tif (error != 0 || dbn == (daddr_t)-1 ||\n\t (ap->a_runp == NULL && ap->a_runb == NULL))\n\t\treturn (error);\n\n\t\/*\n\t * Prepare to back out updates of the fatchain cache after the one\n\t * for the first block done by pcbmap() above. Without the backout,\n\t * then whenever the caller doesn't do i\/o to all of the blocks that\n\t * we find, the single useful cache entry would be too far in advance\n\t * of the actual i\/o to work for the next sequential i\/o. Then the\n\t * FAT would be searched from the beginning. With the backout, the\n\t * FAT is searched starting at most a few blocks early. This wastes\n\t * much less time. Time is also wasted finding more blocks than the\n\t * caller will do i\/o to. This is necessary because the runlength\n\t * parameters are output-only.\n\t *\/\n\tsavefc = dep->de_fc[FC_LASTMAP];\n\n\tcn = de_cluster(pmp, ap->a_loffset);\n\tmp = vp->v_mount;\n\tmaxio = mp->mnt_iosize_max \/ mp->mnt_stat.f_iosize;\n\tbnpercn = de_cn2bn(pmp, 1);\n\tif (ap->a_runp != NULL) {\n\t\tmaxrun = ulmin(maxio - 1, pmp->pm_maxcluster - cn);\n\t\tfor (run = 1; run <= maxrun; run++) {\n\t\t\tif (pcbmap(dep, cn + run, &runbn, NULL, NULL) != 0 ||\n\t\t\t runbn != dbn + run * bnpercn)\n\t\t\t\tbreak;\n\t\t}\n\t\t*ap->a_runp = run - 1;\n\t}\n\tif (ap->a_runb != NULL) {\n\t\tmaxrun = ulmin(maxio - 1, cn);\n\t\tfor (run = 1; run < maxrun; run++) {\n\t\t\tif (pcbmap(dep, cn - run, &runbn, NULL, NULL) != 0 ||\n\t\t\t runbn != dbn - run * bnpercn)\n\t\t\t\tbreak;\n\t\t}\n\t\t*ap->a_runb = run - 1;\n\t}\n\tdep->de_fc[FC_LASTMAP] = savefc;\n\n\treturn (0);\n}\n\nstatic int\nmsdosfs_strategy(struct vop_strategy_args *ap)\n{\n\tstruct bio *bio = ap->a_bio;\n\tstruct bio *nbio;\n\tstruct buf *bp = bio->bio_buf;\n\tstruct vnode *vp = ap->a_vp;\n\tstruct denode *dep = VTODE(vp);\n\tstruct msdosfsmount *pmp = dep->de_pmp;\n\tint error = 0;\n\tdaddr_t dblkno;\n\n\tif (vp->v_type == VBLK || vp->v_type == VCHR)\n\t\tpanic(\"msdosfs_strategy: spec\");\n\t\/*\n\t * If we don't already know the filesystem relative block number\n\t * then get it using pcbmap(). If pcbmap() returns the block\n\t * number as -1 then we've got a hole in the file. DOS filesystems\n\t * don't allow files with holes, so we shouldn't ever see this.\n\t *\/\n\tnbio = push_bio(bio);\n\tif (nbio->bio_offset == NOOFFSET) {\n\t\terror = pcbmap(dep, de_cluster(pmp, bio->bio_offset),\n\t\t\t &dblkno, NULL, NULL);\n\t\tif (error) {\n\t\t\tbp->b_error = error;\n\t\t\tbp->b_flags |= B_ERROR;\n\t\t\t\/* I\/O was never started on nbio, must biodone(bio) *\/\n\t\t\tbiodone(bio);\n\t\t\treturn (error);\n\t\t}\n\t\tif (dblkno == (daddr_t)-1) {\n\t\t\tnbio->bio_offset = NOOFFSET;\n\t\t\tvfs_bio_clrbuf(bp);\n\t\t} else {\n\t\t\tnbio->bio_offset = de_bn2doff(pmp, dblkno);\n\t\t}\n\t}\n\tif (nbio->bio_offset == NOOFFSET) {\n\t\t\/* I\/O was never started on nbio, must biodone(bio) *\/\n\t\tbiodone(bio);\n\t\treturn (0);\n\t}\n\t\/*\n\t * Read\/write the block from\/to the disk that contains the desired\n\t * file block.\n\t *\/\n\tvn_strategy(dep->de_devvp, nbio);\n\treturn (0);\n}\n\nstatic int\nmsdosfs_print(struct vop_print_args *ap)\n{\n\tstruct denode *dep = VTODE(ap->a_vp);\n\n\tkprintf(\"tag VT_MSDOSFS, startcluster %lu, dircluster %lu, \"\n\t\t\"diroffset %lu, dev %d, %d\",\n\t\tdep->de_StartCluster, dep->de_dirclust, dep->de_diroffset,\n\t\tmajor(dep->de_dev), minor(dep->de_dev));\n\tlockmgr_printinfo(&ap->a_vp->v_lock);\n\treturn (0);\n}\n\nstatic int\nmsdosfs_pathconf(struct vop_pathconf_args *ap)\n{\n\tstruct msdosfsmount *pmp = VTODE(ap->a_vp)->de_pmp;\n\n\tswitch (ap->a_name) {\n\tcase _PC_FILESIZEBITS:\n\t\t*ap->a_retval = FAT12(pmp) ? 32 : 33;\n\t\treturn (0);\n\tcase _PC_LINK_MAX:\n\t\t*ap->a_retval = 1;\n\t\treturn (0);\n\tcase _PC_NAME_MAX:\n\t\t*ap->a_retval =\n\t\t pmp->pm_flags & MSDOSFSMNT_LONGNAME ? WIN_MAXLEN : 12;\n\t\treturn (0);\n\tcase _PC_CHOWN_RESTRICTED:\n\t\t*ap->a_retval = 1;\n\t\treturn (0);\n\tcase _PC_NO_TRUNC:\n\t\t*ap->a_retval = 0;\n\t\treturn (0);\n\tdefault:\n\t\treturn (vop_stdpathconf(ap));\n\t}\n\t\/* NOTREACHED *\/\n}\n\n\/* Global vfs data structures for msdosfs *\/\nstruct vop_ops msdosfs_vnode_vops = {\n\t.vop_default =\t\tvop_defaultop,\n\t.vop_access =\t\tmsdosfs_access,\n\t.vop_bmap =\t\tmsdosfs_bmap,\n\t.vop_getpages =\t\tvop_stdgetpages,\n\t.vop_putpages =\t\tvop_stdputpages,\n\t.vop_open =\t\tmsdosfs_open,\n\t.vop_close =\t\tmsdosfs_close,\n\t.vop_old_create =\tmsdosfs_create,\n\t.vop_fsync =\t\tmsdosfs_fsync,\n\t.vop_getattr =\t\tmsdosfs_getattr,\n\t.vop_inactive =\t\tmsdosfs_inactive,\n\t.vop_old_link =\t\tmsdosfs_link,\n\t.vop_old_lookup =\tmsdosfs_lookup,\n\t.vop_old_mkdir =\tmsdosfs_mkdir,\n\t.vop_old_mknod =\tmsdosfs_mknod,\n\t.vop_pathconf =\t\tmsdosfs_pathconf,\n\t.vop_print =\t\tmsdosfs_print,\n\t.vop_read =\t\tmsdosfs_read,\n\t.vop_readdir =\t\tmsdosfs_readdir,\n\t.vop_reclaim =\t\tmsdosfs_reclaim,\n\t.vop_old_remove =\tmsdosfs_remove,\n\t.vop_old_rename =\tmsdosfs_rename,\n\t.vop_old_rmdir =\tmsdosfs_rmdir,\n\t.vop_setattr =\t\tmsdosfs_setattr,\n\t.vop_strategy =\t\tmsdosfs_strategy,\n\t.vop_old_symlink =\tmsdosfs_symlink,\n\t.vop_write =\t\tmsdosfs_write,\n};\n","avg_line_length":27.678974359,"max_line_length":79,"alphanum_fraction":0.654630007} +{"size":4014,"ext":"c","lang":"C","max_stars_count":null,"content":"\/*\n !!DESCRIPTION!! print character frequencies\n !!ORIGIN!! LCC 4.1 Testsuite\n !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC\n*\/\n\n\/*\n cf - print character frequencies\n*\/\n\n#include \"common.h\"\n\n#include \n#include \n#include \n\nFILE *in;\n\n#define INFILE \"cf.in\"\n#define GETCHAR() fgetc(in)\n\n#ifndef NO_FLOATS\nfloat f[0x100];\n#else\nsigned f[0x100];\n#endif\n\n#ifdef NO_OLD_FUNC_DECL\nint main(int argc,char **argv)\n#else\nmain(argc, argv)\nint argc;\nchar *argv[];\n#endif\n{\n int i, c, nc;\n#ifndef NO_FLOATS\n float cutoff, atof();\n#else\n signed cutoff;\n#endif\n\n in = fopen(INFILE, \"rb\");\n if (in == NULL) {\n return EXIT_FAILURE;\n }\n\n if (argc <= 1)\n#ifndef NO_FLOATS\n cutoff = 0.0;\n#else\n cutoff = 0;\n#endif\n else\n#ifndef NO_FLOATS\n cutoff = atof(argv[1])\/100;\n#else\n cutoff = atoi(argv[1])\/100;\n#endif\n for (i = 0; i < 0x100; )\n {\n#ifndef NO_FLOATS\n f[i++] = 0.0;\n#else\n f[i++] = 0;\n#endif\n }\n\n printf(\"input:\\n\\n\");\n\n nc = 0;\n while ((c = GETCHAR()) != -1)\n {\n\/* printf(\"[%02x]\",c); *\/\n printf(\"%c\",c);\n f[c] += 1;\n nc++;\n }\n printf(\"\\n\\ncount: %d\\n\\n\",nc);\n\n \/*\n now try to print a report in a way so that\n the order is somewhat independent from the\n target character set\n *\/\n\n printf(\"a-z char:freq\\n\\n\");\n\n \/* first round ... lowercase characters *\/\n for (i = 0; i < 0x100; ++i)\n {\n if ((f[i]) && ((f[i]\/nc) >= cutoff))\n {\n if ((i >= 'a') && (i <= 'z'))\n {\n printf(\"%c\", i);\n#ifndef NO_FLOATS\n printf(\":%.1f\\n\", 100*f[i]\/nc);\n#else\n printf(\":%d\\n\", 100*f[i]\/nc);\n#endif\n f[i]=0;\n }\n }\n }\n\n printf(\"A-Z char:freq\\n\\n\");\n\n \/* second round ... uppercase characters *\/\n for (i = 0; i < 0x100; ++i)\n {\n if ((f[i]) && ((f[i]\/nc) >= cutoff))\n {\n if ((i >= 'A') && (i <= 'Z'))\n {\n printf(\"%c\", i);\n#ifndef NO_FLOATS\n printf(\":%.1f\\n\", 100*f[i]\/nc);\n#else\n printf(\":%d\\n\", 100*f[i]\/nc);\n#endif\n f[i]=0;\n }\n }\n }\n\n printf(\"0-9 char:freq\\n\\n\");\n\n \/* third round ... numbers *\/\n for (i = 0; i < 0x100; ++i)\n {\n if ((f[i]) && ((f[i]\/nc) >= cutoff))\n {\n if ((i >= '0') && (i <= '9'))\n {\n printf(\"%c\", i);\n#ifndef NO_FLOATS\n printf(\":%.1f\\n\", 100*f[i]\/nc);\n#else\n printf(\":%d\\n\", 100*f[i]\/nc);\n#endif\n f[i]=0;\n }\n }\n }\n\n printf(\"isprint char:freq\\n\\n\");\n\n \/* second last round ... remaining printable characters *\/\n for (i = 0; i < 0x100; ++i)\n {\n if ((f[i]) && ((f[i]\/nc) >= cutoff))\n {\n if(isprint(i))\n {\n printf(\"%c\", i);\n#ifndef NO_FLOATS\n printf(\":%.1f\\n\", 100*f[i]\/nc);\n#else\n printf(\":%d\\n\", 100*f[i]\/nc);\n#endif\n f[i]=0;\n }\n }\n }\n\n printf(\"rest char:freq\\n\\n\");\n\n \/* last round ... remaining non printable characters *\/\n for (i = 0; i < 0x100; ++i)\n {\n if ((f[i]) && ((f[i]\/nc) >= cutoff))\n {\n if(i=='\\n')\n {\n printf(\"newline\");\n }\n else\n {\n printf(\"%03o\", i);\n }\n#ifndef NO_FLOATS\n printf(\":%.1f\\n\", 100*f[i]\/nc);\n#else\n printf(\":%d\\n\", 100*f[i]\/nc);\n#endif\n }\n }\n fclose(in);\n return 0;\n}\n","avg_line_length":20.90625,"max_line_length":78,"alphanum_fraction":0.3858993523} +{"size":2785,"ext":"c","lang":"C","max_stars_count":28.0,"content":"\/* TEMPLATE GENERATED TESTCASE FILE\r\nFilename: CWE114_Process_Control__w32_char_connect_socket_64b.c\r\nLabel Definition File: CWE114_Process_Control__w32.label.xml\r\nTemplate File: sources-sink-64b.tmpl.c\r\n*\/\r\n\/*\r\n * @description\r\n * CWE: 114 Process Control\r\n * BadSource: connect_socket Read data using a connect socket (client side)\r\n * GoodSource: Hard code the full pathname to the library\r\n * Sinks:\r\n * BadSink : Load a dynamic link library\r\n * Flow Variant: 64 Data flow: void pointer to data passed from one function to another in different source files\r\n *\r\n * *\/\r\n\r\n#include \"std_testcase.h\"\r\n\r\n#include \r\n\r\n#ifdef _WIN32\r\n#include \r\n#include \r\n#include \r\n#pragma comment(lib, \"ws2_32\") \/* include ws2_32.lib when linking *\/\r\n#define CLOSE_SOCKET closesocket\r\n#else \/* NOT _WIN32 *\/\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#define INVALID_SOCKET -1\r\n#define SOCKET_ERROR -1\r\n#define CLOSE_SOCKET close\r\n#define SOCKET int\r\n#endif\r\n\r\n#define TCP_PORT 27015\r\n#define IP_ADDRESS \"127.0.0.1\"\r\n\r\n\r\n#ifndef OMITBAD\r\n\r\nvoid CWE114_Process_Control__w32_char_connect_socket_64b_badSink(void * dataVoidPtr)\r\n{\r\n \/* cast void pointer to a pointer of the appropriate type *\/\r\n char * * dataPtr = (char * *)dataVoidPtr;\r\n \/* dereference dataPtr into data *\/\r\n char * data = (*dataPtr);\r\n {\r\n HMODULE hModule;\r\n \/* POTENTIAL FLAW: If the path to the library is not specified, an attacker may be able to\r\n * replace his own file with the intended library *\/\r\n hModule = LoadLibraryA(data);\r\n if (hModule != NULL)\r\n {\r\n FreeLibrary(hModule);\r\n printLine(\"Library loaded and freed successfully\");\r\n }\r\n else\r\n {\r\n printLine(\"Unable to load library\");\r\n }\r\n }\r\n}\r\n\r\n#endif \/* OMITBAD *\/\r\n\r\n#ifndef OMITGOOD\r\n\r\n\/* goodG2B uses the GoodSource with the BadSink *\/\r\nvoid CWE114_Process_Control__w32_char_connect_socket_64b_goodG2BSink(void * dataVoidPtr)\r\n{\r\n \/* cast void pointer to a pointer of the appropriate type *\/\r\n char * * dataPtr = (char * *)dataVoidPtr;\r\n \/* dereference dataPtr into data *\/\r\n char * data = (*dataPtr);\r\n {\r\n HMODULE hModule;\r\n \/* POTENTIAL FLAW: If the path to the library is not specified, an attacker may be able to\r\n * replace his own file with the intended library *\/\r\n hModule = LoadLibraryA(data);\r\n if (hModule != NULL)\r\n {\r\n FreeLibrary(hModule);\r\n printLine(\"Library loaded and freed successfully\");\r\n }\r\n else\r\n {\r\n printLine(\"Unable to load library\");\r\n }\r\n }\r\n}\r\n\r\n#endif \/* OMITGOOD *\/\r\n","avg_line_length":28.7113402062,"max_line_length":114,"alphanum_fraction":0.6438061041} +{"size":4550,"ext":"h","lang":"C","max_stars_count":1.0,"content":"\/*\n* This header is generated by classdump-dyld 1.0\n* on Sunday, September 27, 2020 at 11:52:07 AM Mountain Standard Time\n* Operating System: Version 14.0 (Build 18A373)\n* Image Source: \/System\/Library\/PrivateFrameworks\/MailSupport.framework\/MailSupport\n* classdump-dyld is licensed under GPLv3, Copyright \u00a9 2013-2016 by Elias Limneos.\n*\/\n\n#import \n#import \n#import \n\n@class NSString;\n\n@interface AWDMailNetworkDiagnosticsReport : PBCodable {\n\n\tunsigned long long _numActiveCalls;\n\tunsigned long long _numBackgroundWifiClients;\n\tunsigned long long _timestamp;\n\tNSString* _dataIndicator;\n\tint _dataInterface;\n\tunsigned _reachabilityFlags;\n\tBOOL _cellData;\n\tBOOL _dnsEnabled;\n\tBOOL _roamingAllowed;\n\tBOOL _wifiEnabled;\n\tSCD_Struct_AW5 _has;\n\n}\n\n@property (assign,nonatomic) BOOL hasTimestamp; \n@property (assign,nonatomic) unsigned long long timestamp; \/\/@synthesize timestamp=_timestamp - In the implementation block\n@property (assign,nonatomic) BOOL hasReachabilityFlags; \n@property (assign,nonatomic) unsigned reachabilityFlags; \/\/@synthesize reachabilityFlags=_reachabilityFlags - In the implementation block\n@property (assign,nonatomic) BOOL hasDnsEnabled; \n@property (assign,nonatomic) BOOL dnsEnabled; \/\/@synthesize dnsEnabled=_dnsEnabled - In the implementation block\n@property (assign,nonatomic) BOOL hasWifiEnabled; \n@property (assign,nonatomic) BOOL wifiEnabled; \/\/@synthesize wifiEnabled=_wifiEnabled - In the implementation block\n@property (assign,nonatomic) BOOL hasDataInterface; \n@property (assign,nonatomic) int dataInterface; \/\/@synthesize dataInterface=_dataInterface - In the implementation block\n@property (assign,nonatomic) BOOL hasCellData; \n@property (assign,nonatomic) BOOL cellData; \/\/@synthesize cellData=_cellData - In the implementation block\n@property (nonatomic,readonly) BOOL hasDataIndicator; \n@property (nonatomic,retain) NSString * dataIndicator; \/\/@synthesize dataIndicator=_dataIndicator - In the implementation block\n@property (assign,nonatomic) BOOL hasRoamingAllowed; \n@property (assign,nonatomic) BOOL roamingAllowed; \/\/@synthesize roamingAllowed=_roamingAllowed - In the implementation block\n@property (assign,nonatomic) BOOL hasNumActiveCalls; \n@property (assign,nonatomic) unsigned long long numActiveCalls; \/\/@synthesize numActiveCalls=_numActiveCalls - In the implementation block\n@property (assign,nonatomic) BOOL hasNumBackgroundWifiClients; \n@property (assign,nonatomic) unsigned long long numBackgroundWifiClients; \/\/@synthesize numBackgroundWifiClients=_numBackgroundWifiClients - In the implementation block\n-(unsigned)reachabilityFlags;\n-(void)setHasTimestamp:(BOOL)arg1 ;\n-(void)setDataIndicator:(NSString *)arg1 ;\n-(id)copyWithZone:(NSZone*)arg1 ;\n-(void)writeTo:(id)arg1 ;\n-(BOOL)readFrom:(id)arg1 ;\n-(void)setReachabilityFlags:(unsigned)arg1 ;\n-(unsigned long long)timestamp;\n-(void)setTimestamp:(unsigned long long)arg1 ;\n-(void)setCellData:(BOOL)arg1 ;\n-(void)setDnsEnabled:(BOOL)arg1 ;\n-(void)setRoamingAllowed:(BOOL)arg1 ;\n-(void)setNumActiveCalls:(unsigned long long)arg1 ;\n-(void)setNumBackgroundWifiClients:(unsigned long long)arg1 ;\n-(void)setWifiEnabled:(BOOL)arg1 ;\n-(NSString *)dataIndicator;\n-(void)mergeFrom:(id)arg1 ;\n-(void)copyTo:(id)arg1 ;\n-(BOOL)isEqual:(id)arg1 ;\n-(BOOL)hasTimestamp;\n-(unsigned long long)hash;\n-(BOOL)wifiEnabled;\n-(id)description;\n-(id)dictionaryRepresentation;\n-(void)setHasReachabilityFlags:(BOOL)arg1 ;\n-(BOOL)hasReachabilityFlags;\n-(void)setHasDnsEnabled:(BOOL)arg1 ;\n-(BOOL)hasDnsEnabled;\n-(void)setHasWifiEnabled:(BOOL)arg1 ;\n-(BOOL)hasWifiEnabled;\n-(void)setDataInterface:(int)arg1 ;\n-(void)setHasDataInterface:(BOOL)arg1 ;\n-(BOOL)hasDataInterface;\n-(void)setHasCellData:(BOOL)arg1 ;\n-(BOOL)hasCellData;\n-(BOOL)hasDataIndicator;\n-(void)setHasRoamingAllowed:(BOOL)arg1 ;\n-(BOOL)hasRoamingAllowed;\n-(void)setHasNumActiveCalls:(BOOL)arg1 ;\n-(BOOL)hasNumActiveCalls;\n-(void)setHasNumBackgroundWifiClients:(BOOL)arg1 ;\n-(BOOL)hasNumBackgroundWifiClients;\n-(BOOL)dnsEnabled;\n-(int)dataInterface;\n-(BOOL)cellData;\n-(BOOL)roamingAllowed;\n-(unsigned long long)numActiveCalls;\n-(unsigned long long)numBackgroundWifiClients;\n@end\n\n","avg_line_length":45.0495049505,"max_line_length":181,"alphanum_fraction":0.7406593407} +{"size":2152,"ext":"h","lang":"C","max_stars_count":null,"content":"\/* poly1305.h\n *\n * Copyright (C) 2006-2014 wolfSSL Inc.\n *\n * This file is part of CyaSSL.\n *\n * CyaSSL is free software; you can redistribute it and\/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * CyaSSL is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\n *\/\n\n\n#ifdef HAVE_POLY1305\n\n#ifndef CTAO_CRYPT_POLY1305_H\n#define CTAO_CRYPT_POLY1305_H\n\n#include \n\n#ifdef __cplusplus\n extern \"C\" {\n#endif\n\n\/* auto detect between 32bit \/ 64bit *\/\n#define HAS_SIZEOF_INT128_64BIT (defined(__SIZEOF_INT128__) && defined(__LP64__))\n#define HAS_MSVC_64BIT (defined(_MSC_VER) && defined(_M_X64))\n#define HAS_GCC_4_4_64BIT (defined(__GNUC__) && defined(__LP64__) && \\\n ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))))\n\n#if (HAS_SIZEOF_INT128_64BIT || HAS_MSVC_64BIT || HAS_GCC_4_4_64BIT)\n#define POLY130564\n#else\n#define POLY130532\n#endif\n\nenum {\n POLY1305 = 7,\n POLY1305_BLOCK_SIZE = 16,\n POLY1305_DIGEST_SIZE = 16,\n POLY1305_PAD_SIZE = 56\n};\n\n\/* Poly1305 state *\/\ntypedef struct Poly1305 {\n#if defined(POLY130564)\n\tword64 r[3];\n\tword64 h[3];\n\tword64 pad[2];\n#else\n\tword32 r[5];\n\tword32 h[5];\n\tword32 pad[4];\n#endif\n\tsize_t leftover;\n\tunsigned char buffer[POLY1305_BLOCK_SIZE];\n\tunsigned char final;\n} Poly1305;\n\n\n\/* does init *\/\n\nCYASSL_API int Poly1305SetKey(Poly1305* poly1305, const byte* key, word32 kySz);\nCYASSL_API int Poly1305Update(Poly1305* poly1305, const byte*, word32);\nCYASSL_API int Poly1305Final(Poly1305* poly1305, byte* tag);\n\n#ifdef __cplusplus\n } \/* extern \"C\" *\/\n#endif\n\n#endif \/* CTAO_CRYPT_POLY1305_H *\/\n\n#endif \/* HAVE_POLY1305 *\/\n\n","avg_line_length":25.619047619,"max_line_length":81,"alphanum_fraction":0.7263011152} +{"size":3319,"ext":"c","lang":"C","max_stars_count":3.0,"content":"#include \/\/ init.h \ud5e4\ub354\ud30c\uc77c \ucd94\uac00\n#include \/\/ module.h \ud5e4\ub354\ud30c\uc77c \ucd94\uac00\n#include \/\/ kernel.h \ud5e4\ub354\ud30c\uc77c \ucd94\uac00\n#include \/\/ list.h \ud5e4\ub354\ud30c\uc77c \ucd94\uac00\n#include \/\/ slab.h \ud5e4\ub354\ud30c\uc77c \ucd94\uac00\n\nstruct birthday\n{\n int month; \/\/ \uc6d4\n int day; \/\/ \uc77c\n int year; \/\/ \ub144\n \n struct list_head list; \/\/ *next, *perv \ubcc0\uc218\ub97c \ud1b5\ud574 \ub9ac\uc2a4\ud2b8 \ub178\ub4dc\ub97c \uc5f0\uacb0\ud560 \uc218 \uc788\uac8c \ud55c\ub2e4.\n};\n\nstatic LIST_HEAD(birthday_list); \/\/ \uc0dd\uc77c \uc815\ubcf4\ub97c \uc5f0\uacb0\ub9ac\uc2a4\ud2b8\uc5d0 \ub2f4\uc744 \uc218 \uc788\ub3c4\ub85d, birthday_list\ub77c\ub294 \uc774\ub984\uc73c\ub85c \uc5f0\uacb0\ub9ac\uc2a4\ud2b8\uc758 \ud5e4\ub4dc \ud3ec\uc778\ud130(\uc2dc\uc791\uc810)\ub97c \ucd08\uae30\ud654\ud55c\ub2e4.\n\nint module_birthday_init(void) {\n struct birthday *person; \/\/ birthday \ud3ec\uc778\ud130\ub97c \ub2f4\uc744 \uc218 \uc788\ub3c4\ub85d \uc120\uc5b8\ud55c \uc784\uc2dc\ubcc0\uc218\uc774\ub2e4.\n person = kmalloc(sizeof(*person), GFP_KERNEL); \/\/ birthday \ud3ec\uc778\ud130\uc758 \ud06c\uae30\ub9cc\ud07c, \ucee4\ub110\uc6a9 \uba54\ubaa8\ub9ac\ub97c \ud560\ub2f9\ud55c\ub2e4.\n person->month = 7;\n person->day = 8;\n person->year = 1996;\n\n INIT_LIST_HEAD(&person->list); \/\/ list_head\uc758 \uac01 \ud56d\ubaa9\uc744 \ucd08\uae30\ud654 \ud55c\ub2e4.\n list_add_tail(&person->list, &birthday_list); \/\/ \uc704\uc758 \ud56d\ubaa9\uc744 \uc5f0\uacb0\ub9ac\uc2a4\ud2b8\uc5d0 \ucd94\uac00\ud55c\ub2e4.\n \n person = kmalloc(sizeof(*person), GFP_KERNEL);\n person->month = 12;\n person->day = 28;\n person->year = 2000;\n INIT_LIST_HEAD(&person->list); \/\/ list_head\uc758 \uac01 \ud56d\ubaa9\uc744 \ucd08\uae30\ud654 \ud55c\ub2e4.\n list_add_tail(&person->list, &birthday_list); \/\/ \uc704\uc758 \ud56d\ubaa9\uc744 \uc5f0\uacb0\ub9ac\uc2a4\ud2b8\uc5d0 \ucd94\uac00\ud55c\ub2e4.\n\n person = kmalloc(sizeof(*person), GFP_KERNEL);\n person->month = 2;\n person->day = 1;\n person->year = 2000;\n INIT_LIST_HEAD(&person->list); \/\/ list_head\uc758 \uac01 \ud56d\ubaa9\uc744 \ucd08\uae30\ud654 \ud55c\ub2e4.\n list_add_tail(&person->list, &birthday_list); \/\/ \uc704\uc758 \ud56d\ubaa9\uc744 \uc5f0\uacb0\ub9ac\uc2a4\ud2b8\uc5d0 \ucd94\uac00\ud55c\ub2e4.\n\n person = kmalloc(sizeof(*person), GFP_KERNEL);\n person->month = 6;\n person->day = 3;\n person->year = 1234;\n INIT_LIST_HEAD(&person->list); \/\/ list_head\uc758 \uac01 \ud56d\ubaa9\uc744 \ucd08\uae30\ud654 \ud55c\ub2e4.\n list_add_tail(&person->list, &birthday_list); \/\/ \uc704\uc758 \ud56d\ubaa9\uc744 \uc5f0\uacb0\ub9ac\uc2a4\ud2b8\uc5d0 \ucd94\uac00\ud55c\ub2e4.\n\n list_for_each_entry(person, &birthday_list, list) \/\/ person \ubcc0\uc218\uac00 cursor\uc5ed\ud560\uc744 \ud558\uc5ec \uc21c\ud68c\ud558\ub77c. \uc21c\ud68c \ub300\uc0c1\uc740 birthday_List\uc774\ub2e4. list_head\ub294 list\ub77c\ub294 \ubcc0\uc218(\uba64\ubc84)\uc758 \uc774\ub984\uc73c\ub85c \uc800\uc7a5\ub418\uc5b4\uc788\ub2e4.\n { \/\/ node\ub97c \uc21c\ucc28\uc801\uc73c\ub85c \uc811\uadfc\ud560 \uc218 \uc788\ub3c4\ub85d \ud558\ub294 \ub9e4\ud06c\ub85c\uc774\ub2e4.\n printk(KERN_INFO \"person %d %d %d\\n\", person->month,\n person->day, person->year); \/\/ <6> KERN_INFO \ub808\ubca8\uc5d0\uc11c \uc0dd\uc77c\uc5d0 \ub300\ud55c \uc815\ubcf4 \ub85c\uadf8 \ucd9c\ub825\n }\n return 0; \/\/ \uc815\uc0c1\uc801\uc778 \uc885\ub8cc\ub97c \uc54c\ub9bc\n}\n\nvoid module_birthday_exit(void) {\n struct birthday *ptr, *next; \/\/ \ubc11\uc758 \uc21c\ud68c \ub9e4\ud06c\ub85c\ub97c \uc0ac\uc6a9\ud558\uae30 \uc704\ud574\uc11c cursor\uacfc \uc784\uc2dc\ubcc0\uc218 next\ub97c \uc120\uc5b8.\n list_for_each_entry_safe(ptr, next, &birthday_list, list) \/\/ prt \ubcc0\uc218\uac00 cursor \uc5ed\ud560\uc744 \ud558\uc5ec \uc21c\ud68c\ud558\ub77c. next\ub97c \uc784\uc2dc\ubcc0\uc218\ub85c \uc0ac\uc6a9\ud558\uba70, \uc21c\ud68c \ub300\uc0c1(HEAD)\uc740 birthday_list\uc774\ub2e4.\n { \/\/ list_head\ub294 list\ub77c\ub294 \ubcc0\uc218(\uba64\ubc84)\uc758 \uc774\ub984\uc73c\ub85c \uc800\uc7a5\ub418\uc5b4\uc788\ub2e4.\n \/\/ list_for_each_entry_safe\ub294 list_for_each_entry\uc640 \ub2e4\ub974\uac8c \uc21c\ud68c \uc911\uac04\uc5d0 node\uac00 \uc0ad\uc81c\ub418\uc5b4\ub3c4 \uc815\uc9c0\ud558\uc9c0 \uc54a\ub294\ub2e4.\n printk(KERN_INFO \"Removing %d %d %d\\n\", ptr->month,\n ptr->day, ptr->year); \/\/ <6> KERN_INFO \ub808\ubca8\uc5d0\uc11c \uc0ad\uc81c\ud560 \uc0dd\uc77c\uc5d0 \ub300\ud55c \uc815\ubcf4 \ub85c\uadf8 \ucd9c\ub825\n list_del(&ptr->list); \/\/ ptr\ud3ec\uc778\ud130\uc5d0 \ub2f4\uae34 \uc5d4\ud2b8\ub9ac(node)\ub97c \uc0ad\uc81c\ud55c\ub2e4.\n kfree(ptr); \/\/ \ub3d9\uc801\ud560\ub2f9\ub41c ptr \uba54\ubaa8\ub9ac\ub97c \ubc18\ub0a9\ud55c\ub2e4.\n }\n}\n\nmodule_init(module_birthday_init); \/\/ \uc720\uc800\ub808\ubca8\uc5d0\uc11c insmod\ub97c \ud1b5\ud574 birthday.ko\ub97c \uc801\uc7ac\ud560 \uacbd\uc6b0, module_birthday_init \ud568\uc218\uac00 \ud638\ucd9c\ub418\ub3c4\ub85d \ud55c\ub2e4.\nmodule_exit(module_birthday_exit); \/\/ \uc720\uc800\ub808\ubca8\uc5d0\uc11c rmmod\ub97c \ud1b5\ud574 birthday.ko \ubaa8\ub4c8\uc744 \ud574\uc81c\ud560 \uacbd\uc6b0, module_birthday_exit \ud568\uc218\uac00 \ud638\ucd9c\ub418\ub3c4\ub85d \ud55c\ub2e4.\n\nMODULE_LICENSE(\"GPL\"); \/\/ birthday.ko \ubaa8\ub4c8\uc758 \ub77c\uc774\uc120\uc2a4\ub97c GPL(GNU Public License)\ub85c \uc9c0\uc815\ud558\uc5ec \uc624\ud508 \uc18c\uc2a4\uc784\uc744 \uba85\uc2dc\ud55c\ub2e4.\nMODULE_DESCRIPTION(\"Birthday List\"); \/\/ \ubaa8\ub4c8\uc758 \uc124\uba85\uc744 Birthday List\ub85c \ud55c\ub2e4.\nMODULE_AUTHOR(\"LANI\"); \/\/ \ubaa8\ub4c8 \uc81c\uc791\uc790\ub97c LANI\ub85c \ud55c\ub2e4.\n","avg_line_length":44.2533333333,"max_line_length":150,"alphanum_fraction":0.6257909009} +{"size":2404,"ext":"h","lang":"C","max_stars_count":4.0,"content":"\/*=========================================================================\r\n\r\n Program: Visualization Toolkit\r\n Module: vtkImageGaussianSource.h\r\n\r\n Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen\r\n All rights reserved.\r\n See Copyright.txt or http:\/\/www.kitware.com\/Copyright.htm for details.\r\n\r\n This software is distributed WITHOUT ANY WARRANTY; without even\r\n the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\r\n PURPOSE. See the above copyright notice for more information.\r\n\r\n=========================================================================*\/\r\n\/**\r\n * @class vtkImageGaussianSource\r\n * @brief Create an image with Gaussian pixel values.\r\n *\r\n * vtkImageGaussianSource just produces images with pixel values determined\r\n * by a Gaussian.\r\n*\/\r\n\r\n#ifndef vtkImageGaussianSource_h\r\n#define vtkImageGaussianSource_h\r\n\r\n#include \"vtkImagingSourcesModule.h\" \/\/ For export macro\r\n#include \"vtkImageAlgorithm.h\"\r\n\r\nclass VTKIMAGINGSOURCES_EXPORT vtkImageGaussianSource : public vtkImageAlgorithm\r\n{\r\npublic:\r\n static vtkImageGaussianSource *New();\r\n vtkTypeMacro(vtkImageGaussianSource,vtkImageAlgorithm);\r\n void PrintSelf(ostream& os, vtkIndent indent);\r\n\r\n \/**\r\n * Set\/Get the extent of the whole output image.\r\n *\/\r\n void SetWholeExtent(int xMinx, int xMax, int yMin, int yMax,\r\n int zMin, int zMax);\r\n\r\n \/\/@{\r\n \/**\r\n * Set\/Get the center of the Gaussian.\r\n *\/\r\n vtkSetVector3Macro(Center, double);\r\n vtkGetVector3Macro(Center, double);\r\n \/\/@}\r\n\r\n \/\/@{\r\n \/**\r\n * Set\/Get the Maximum value of the gaussian\r\n *\/\r\n vtkSetMacro(Maximum, double);\r\n vtkGetMacro(Maximum, double);\r\n \/\/@}\r\n\r\n \/\/@{\r\n \/**\r\n * Set\/Get the standard deviation of the gaussian\r\n *\/\r\n vtkSetMacro(StandardDeviation, double);\r\n vtkGetMacro(StandardDeviation, double);\r\n \/\/@}\r\n\r\nprotected:\r\n vtkImageGaussianSource();\r\n ~vtkImageGaussianSource() {}\r\n\r\n double StandardDeviation;\r\n int WholeExtent[6];\r\n double Center[3];\r\n double Maximum;\r\n\r\n virtual int RequestInformation (vtkInformation *, vtkInformationVector**, vtkInformationVector *);\r\n virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);\r\nprivate:\r\n vtkImageGaussianSource(const vtkImageGaussianSource&) VTK_DELETE_FUNCTION;\r\n void operator=(const vtkImageGaussianSource&) VTK_DELETE_FUNCTION;\r\n};\r\n\r\n\r\n#endif\r\n","avg_line_length":28.619047619,"max_line_length":101,"alphanum_fraction":0.6634775374} +{"size":51767,"ext":"h","lang":"C","max_stars_count":2.0,"content":"\/** @file\n Copyright (C) 2019, vit9696. All rights reserved.\n\n All rights reserved.\n\n This program and the accompanying materials\n are licensed and made available under the terms and conditions of the BSD License\n which accompanies this distribution. The full text of the license may be found at\n http:\/\/opensource.org\/licenses\/bsd-license.php\n\n THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\n**\/\n\n#ifndef OC_CONFIGURATION_LIB_H\n#define OC_CONFIGURATION_LIB_H\n\n#include \n#include \n#include \n\n\/**\n ACPI section\n**\/\n\n\/\/\/\n\/\/\/ ACPI added tables.\n\/\/\/\n#define OC_ACPI_ADD_ENTRY_FIELDS(_, __) \\\n _(BOOLEAN , Enabled , , FALSE , () ) \\\n _(OC_STRING , Comment , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Path , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) )\n OC_DECLARE (OC_ACPI_ADD_ENTRY)\n\n#define OC_ACPI_ADD_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_ACPI_ADD_ENTRY, _, __)\n OC_DECLARE (OC_ACPI_ADD_ARRAY)\n\n\/\/\/\n\/\/\/ ACPI table deletion.\n\/\/\/\n#define OC_ACPI_DELETE_ENTRY_FIELDS(_, __) \\\n _(BOOLEAN , All , , FALSE , () ) \\\n _(BOOLEAN , Enabled , , FALSE , () ) \\\n _(OC_STRING , Comment , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(UINT8 , OemTableId , [8] , {0} , () ) \\\n _(UINT32 , TableLength , , 0 , () ) \\\n _(UINT8 , TableSignature , [4] , {0} , () )\n OC_DECLARE (OC_ACPI_DELETE_ENTRY)\n\n#define OC_ACPI_DELETE_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_ACPI_DELETE_ENTRY, _, __)\n OC_DECLARE (OC_ACPI_DELETE_ARRAY)\n\n\/\/\/\n\/\/\/ ACPI patches.\n\/\/\/\n#define OC_ACPI_PATCH_ENTRY_FIELDS(_, __) \\\n _(UINT32 , Count , , 0 , () ) \\\n _(BOOLEAN , Enabled , , FALSE , () ) \\\n _(OC_STRING , Comment , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_DATA , Find , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \\\n _(OC_STRING , Base , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(UINT32 , BaseSkip , , 0 , () ) \\\n _(UINT32 , Limit , , 0 , () ) \\\n _(OC_DATA , Mask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \\\n _(OC_DATA , Replace , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \\\n _(OC_DATA , ReplaceMask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \\\n _(UINT8 , OemTableId , [8] , {0} , () ) \\\n _(UINT32 , TableLength , , 0 , () ) \\\n _(UINT8 , TableSignature , [4] , {0} , () ) \\\n _(UINT32 , Skip , , 0 , () )\n OC_DECLARE (OC_ACPI_PATCH_ENTRY)\n\n#define OC_ACPI_PATCH_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_ACPI_PATCH_ENTRY, _, __)\n OC_DECLARE (OC_ACPI_PATCH_ARRAY)\n\n\/\/\/\n\/\/\/ ACPI quirks.\n\/\/\/\n#define OC_ACPI_QUIRKS_FIELDS(_, __) \\\n _(BOOLEAN , FadtEnableReset , , FALSE , ()) \\\n _(BOOLEAN , NormalizeHeaders , , FALSE , ()) \\\n _(BOOLEAN , RebaseRegions , , FALSE , ()) \\\n _(BOOLEAN , ResetHwSig , , FALSE , ()) \\\n _(BOOLEAN , ResetLogoStatus , , FALSE , ()) \\\n _(BOOLEAN , SyncTableIds , , FALSE , ())\n OC_DECLARE (OC_ACPI_QUIRKS)\n\n#define OC_ACPI_CONFIG_FIELDS(_, __) \\\n _(OC_ACPI_ADD_ARRAY , Add , , OC_CONSTR2 (OC_ACPI_ADD_ARRAY, _, __) , OC_DESTR (OC_ACPI_ADD_ARRAY)) \\\n _(OC_ACPI_DELETE_ARRAY , Delete , , OC_CONSTR2 (OC_ACPI_DELETE_ARRAY, _, __) , OC_DESTR (OC_ACPI_DELETE_ARRAY)) \\\n _(OC_ACPI_PATCH_ARRAY , Patch , , OC_CONSTR2 (OC_ACPI_PATCH_ARRAY, _, __) , OC_DESTR (OC_ACPI_PATCH_ARRAY)) \\\n _(OC_ACPI_QUIRKS , Quirks , , OC_CONSTR2 (OC_ACPI_QUIRKS, _, __) , OC_DESTR (OC_ACPI_QUIRKS))\n OC_DECLARE (OC_ACPI_CONFIG)\n\n\/**\n Apple bootloader section\n**\/\n\n#define OC_BOOTER_WL_ENTRY_FIELDS(_, __) \\\n _(UINT64 , Address , , 0 , () ) \\\n _(BOOLEAN , Enabled , , FALSE , () ) \\\n _(OC_STRING , Comment , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) )\n OC_DECLARE (OC_BOOTER_WL_ENTRY)\n\n#define OC_BOOTER_WL_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_BOOTER_WL_ENTRY, _, __)\n OC_DECLARE (OC_BOOTER_WL_ARRAY)\n\n\/\/\/\n\/\/\/ Bootloader patches.\n\/\/\/\n#define OC_BOOTER_PATCH_ENTRY_FIELDS(_, __) \\\n _(OC_STRING , Arch , , OC_STRING_CONSTR (\"Any\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Comment , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(UINT32 , Count , , 0 , () ) \\\n _(BOOLEAN , Enabled , , FALSE , () ) \\\n _(OC_DATA , Find , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \\\n _(OC_STRING , Identifier , , OC_STRING_CONSTR (\"Any\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_DATA , Mask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \\\n _(OC_DATA , Replace , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \\\n _(OC_DATA , ReplaceMask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \\\n _(UINT32 , Limit , , 0 , () ) \\\n _(UINT32 , Skip , , 0 , () )\n OC_DECLARE (OC_BOOTER_PATCH_ENTRY)\n\n#define OC_BOOTER_PATCH_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_BOOTER_PATCH_ENTRY, _, __)\n OC_DECLARE (OC_BOOTER_PATCH_ARRAY)\n\n\/\/\/\n\/\/\/ Apple bootloader quirks.\n\/\/\/\n#define OC_BOOTER_QUIRKS_FIELDS(_, __) \\\n _(BOOLEAN , AllowRelocationBlock , , FALSE , ()) \\\n _(BOOLEAN , AvoidRuntimeDefrag , , FALSE , ()) \\\n _(BOOLEAN , DevirtualiseMmio , , FALSE , ()) \\\n _(BOOLEAN , DisableSingleUser , , FALSE , ()) \\\n _(BOOLEAN , DisableVariableWrite , , FALSE , ()) \\\n _(BOOLEAN , DiscardHibernateMap , , FALSE , ()) \\\n _(BOOLEAN , EnableSafeModeSlide , , FALSE , ()) \\\n _(BOOLEAN , EnableWriteUnprotector , , FALSE , ()) \\\n _(BOOLEAN , ForceBooterSignature , , FALSE , ()) \\\n _(BOOLEAN , ForceExitBootServices , , FALSE , ()) \\\n _(BOOLEAN , ProtectMemoryRegions , , FALSE , ()) \\\n _(BOOLEAN , ProtectSecureBoot , , FALSE , ()) \\\n _(BOOLEAN , ProtectUefiServices , , FALSE , ()) \\\n _(BOOLEAN , ProvideCustomSlide , , FALSE , ()) \\\n _(UINT8 , ProvideMaxSlide , , 0 , ()) \\\n _(BOOLEAN , RebuildAppleMemoryMap , , FALSE , ()) \\\n _(BOOLEAN , SetupVirtualMap , , FALSE , ()) \\\n _(BOOLEAN , SignalAppleOS , , FALSE , ()) \\\n _(BOOLEAN , SyncRuntimePermissions , , FALSE , ())\n OC_DECLARE (OC_BOOTER_QUIRKS)\n\n\/\/\/\n\/\/\/ Apple bootloader section.\n\/\/\/\n#define OC_BOOTER_CONFIG_FIELDS(_, __) \\\n _(OC_BOOTER_WL_ARRAY , MmioWhitelist , , OC_CONSTR2 (OC_BOOTER_WL_ARRAY, _, __) , OC_DESTR (OC_BOOTER_WL_ARRAY)) \\\n _(OC_BOOTER_PATCH_ARRAY , Patch , , OC_CONSTR2 (OC_BOOTER_PATCH_ARRAY, _, __) , OC_DESTR (OC_BOOTER_PATCH_ARRAY)) \\\n _(OC_BOOTER_QUIRKS , Quirks , , OC_CONSTR2 (OC_BOOTER_QUIRKS, _, __) , OC_DESTR (OC_BOOTER_QUIRKS))\n OC_DECLARE (OC_BOOTER_CONFIG)\n\n\/**\n DeviceProperties section\n**\/\n\n\/\/\/\n\/\/\/ Device properties is an associative map of devices with their property key value maps.\n\/\/\/\n#define OC_DEV_PROP_ADD_MAP_FIELDS(_, __) \\\n OC_MAP (OC_STRING, OC_ASSOC, _, __)\n OC_DECLARE (OC_DEV_PROP_ADD_MAP)\n\n#define OC_DEV_PROP_DELETE_ENTRY_FIELDS(_, __) \\\n OC_ARRAY (OC_STRING, _, __)\n OC_DECLARE (OC_DEV_PROP_DELETE_ENTRY)\n\n#define OC_DEV_PROP_DELETE_MAP_FIELDS(_, __) \\\n OC_MAP (OC_STRING, OC_DEV_PROP_DELETE_ENTRY, _, __)\n OC_DECLARE (OC_DEV_PROP_DELETE_MAP)\n\n#define OC_DEV_PROP_CONFIG_FIELDS(_, __) \\\n _(OC_DEV_PROP_ADD_MAP , Add , , OC_CONSTR2 (OC_DEV_PROP_ADD_MAP, _, __) , OC_DESTR (OC_DEV_PROP_ADD_MAP)) \\\n _(OC_DEV_PROP_DELETE_MAP , Delete , , OC_CONSTR2 (OC_DEV_PROP_DELETE_MAP, _, __) , OC_DESTR (OC_DEV_PROP_DELETE_MAP))\n OC_DECLARE (OC_DEV_PROP_CONFIG)\n\n\/**\n KernelSpace section\n**\/\n\n\/\/\/\n\/\/\/ KernelSpace kext adds.\n\/\/\/\n#define OC_KERNEL_ADD_ENTRY_FIELDS(_, __) \\\n _(BOOLEAN , Enabled , , FALSE , () ) \\\n _(OC_STRING , Arch , , OC_STRING_CONSTR (\"Any\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Comment , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , MaxKernel , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , MinKernel , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Identifier , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , BundlePath , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , ExecutablePath , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , PlistPath , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(UINT8 * , ImageData , , NULL , OcFreePointer ) \\\n _(UINT32 , ImageDataSize , , 0 , () ) \\\n _(CHAR8 * , PlistData , , NULL , OcFreePointer ) \\\n _(UINT32 , PlistDataSize , , 0 , () )\n OC_DECLARE (OC_KERNEL_ADD_ENTRY)\n\n#define OC_KERNEL_ADD_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_KERNEL_ADD_ENTRY, _, __)\n OC_DECLARE (OC_KERNEL_ADD_ARRAY)\n\n\/\/\/\n\/\/\/ KernelSpace kext blocks.\n\/\/\/\n#define OC_KERNEL_BLOCK_ENTRY_FIELDS(_, __) \\\n _(BOOLEAN , Enabled , , FALSE , () ) \\\n _(OC_STRING , Arch , , OC_STRING_CONSTR (\"Any\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Comment , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Identifier , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , MaxKernel , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , MinKernel , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) )\n OC_DECLARE (OC_KERNEL_BLOCK_ENTRY)\n\n#define OC_KERNEL_BLOCK_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_KERNEL_BLOCK_ENTRY, _, __)\n OC_DECLARE (OC_KERNEL_BLOCK_ARRAY)\n\n\/\/\/\n\/\/\/ Kernel emulation preferences.\n\/\/\/\n#define OC_KERNEL_EMULATE_FIELDS(_,__) \\\n _(UINT32 , Cpuid1Data , [4] , {0} , () ) \\\n _(UINT32 , Cpuid1Mask , [4] , {0} , () ) \\\n _(BOOLEAN , DummyPowerManagement, , FALSE , () ) \\\n _(OC_STRING , MaxKernel , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , MinKernel , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) )\n OC_DECLARE (OC_KERNEL_EMULATE)\n\n\/\/\/\n\/\/\/ KernelSpace forced loaded kexts.\n\/\/\/\n#define OC_KERNEL_FORCE_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_KERNEL_ADD_ENTRY, _, __)\n OC_DECLARE (OC_KERNEL_FORCE_ARRAY)\n\n\/\/\/\n\/\/\/ KernelSpace patches.\n\/\/\/\n#define OC_KERNEL_PATCH_ENTRY_FIELDS(_, __) \\\n _(OC_STRING , Arch , , OC_STRING_CONSTR (\"Any\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Base , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Comment , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(UINT32 , Count , , 0 , () ) \\\n _(BOOLEAN , Enabled , , FALSE , () ) \\\n _(OC_DATA , Find , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \\\n _(OC_STRING , Identifier , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_DATA , Mask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \\\n _(OC_STRING , MaxKernel , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , MinKernel , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_DATA , Replace , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \\\n _(OC_DATA , ReplaceMask , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA) ) \\\n _(UINT32 , Limit , , 0 , () ) \\\n _(UINT32 , Skip , , 0 , () )\n OC_DECLARE (OC_KERNEL_PATCH_ENTRY)\n\n#define OC_KERNEL_PATCH_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_KERNEL_PATCH_ENTRY, _, __)\n OC_DECLARE (OC_KERNEL_PATCH_ARRAY)\n\n\/\/\/\n\/\/\/ KernelSpace quirks.\n\/\/\/\n#define OC_KERNEL_QUIRKS_FIELDS(_, __) \\\n _(INT64 , SetApfsTrimTimeout , , -1 , ()) \\\n _(BOOLEAN , AppleCpuPmCfgLock , , FALSE , ()) \\\n _(BOOLEAN , AppleXcpmCfgLock , , FALSE , ()) \\\n _(BOOLEAN , AppleXcpmExtraMsrs , , FALSE , ()) \\\n _(BOOLEAN , AppleXcpmForceBoost , , FALSE , ()) \\\n _(BOOLEAN , CustomSmbiosGuid , , FALSE , ()) \\\n _(BOOLEAN , DisableIoMapper , , FALSE , ()) \\\n _(BOOLEAN , DisableLinkeditJettison , , FALSE , ()) \\\n _(BOOLEAN , DisableRtcChecksum , , FALSE , ()) \\\n _(BOOLEAN , ExtendBTFeatureFlags , , FALSE , ()) \\\n _(BOOLEAN , ExternalDiskIcons , , FALSE , ()) \\\n _(BOOLEAN , ForceSecureBootScheme , , FALSE , ()) \\\n _(BOOLEAN , IncreasePciBarSize , , FALSE , ()) \\\n _(BOOLEAN , LapicKernelPanic , , FALSE , ()) \\\n _(BOOLEAN , LegacyCommpage , , FALSE , ()) \\\n _(BOOLEAN , PanicNoKextDump , , FALSE , ()) \\\n _(BOOLEAN , PowerTimeoutKernelPanic , , FALSE , ()) \\\n _(BOOLEAN , ProvideCurrentCpuInfo , , FALSE , ()) \\\n _(BOOLEAN , ThirdPartyDrives , , FALSE , ()) \\\n _(BOOLEAN , XhciPortLimit , , FALSE , ())\n OC_DECLARE (OC_KERNEL_QUIRKS)\n\n\/\/\/\n\/\/\/ KernelSpace operation scheme.\n\/\/\/\n#define OC_KERNEL_SCHEME_FIELDS(_, __) \\\n _(OC_STRING , KernelArch , , OC_STRING_CONSTR (\"Auto\", _, __), OC_DESTR (OC_STRING)) \\\n _(OC_STRING , KernelCache , , OC_STRING_CONSTR (\"Auto\", _, __), OC_DESTR (OC_STRING)) \\\n _(BOOLEAN , CustomKernel , , FALSE , ()) \\\n _(BOOLEAN , FuzzyMatch , , FALSE , ())\n OC_DECLARE (OC_KERNEL_SCHEME)\n\n#define OC_KERNEL_CONFIG_FIELDS(_, __) \\\n _(OC_KERNEL_ADD_ARRAY , Add , , OC_CONSTR2 (OC_KERNEL_ADD_ARRAY, _, __) , OC_DESTR (OC_KERNEL_ADD_ARRAY)) \\\n _(OC_KERNEL_BLOCK_ARRAY , Block , , OC_CONSTR2 (OC_KERNEL_BLOCK_ARRAY, _, __) , OC_DESTR (OC_KERNEL_BLOCK_ARRAY)) \\\n _(OC_KERNEL_EMULATE , Emulate , , OC_CONSTR2 (OC_KERNEL_EMULATE, _, __) , OC_DESTR (OC_KERNEL_EMULATE)) \\\n _(OC_KERNEL_FORCE_ARRAY , Force , , OC_CONSTR2 (OC_KERNEL_FORCE_ARRAY, _, __) , OC_DESTR (OC_KERNEL_FORCE_ARRAY)) \\\n _(OC_KERNEL_PATCH_ARRAY , Patch , , OC_CONSTR2 (OC_KERNEL_PATCH_ARRAY, _, __) , OC_DESTR (OC_KERNEL_PATCH_ARRAY)) \\\n _(OC_KERNEL_QUIRKS , Quirks , , OC_CONSTR2 (OC_KERNEL_QUIRKS, _, __) , OC_DESTR (OC_KERNEL_QUIRKS)) \\\n _(OC_KERNEL_SCHEME , Scheme , , OC_CONSTR2 (OC_KERNEL_SCHEME, _, __) , OC_DESTR (OC_KERNEL_SCHEME))\n OC_DECLARE (OC_KERNEL_CONFIG)\n\n\/**\n Misc section\n**\/\n\n#define OC_MISC_BLESS_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_STRING, _, __)\n OC_DECLARE (OC_MISC_BLESS_ARRAY)\n\n#define OC_MISC_BOOT_FIELDS(_, __) \\\n _(OC_STRING , PickerMode , , OC_STRING_CONSTR (\"Builtin\", _, __) , OC_DESTR (OC_STRING)) \\\n _(OC_STRING , HibernateMode , , OC_STRING_CONSTR (\"None\", _, __) , OC_DESTR (OC_STRING)) \\\n _(OC_STRING , LauncherOption , , OC_STRING_CONSTR (\"Disabled\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , LauncherPath , , OC_STRING_CONSTR (\"Default\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(UINT32 , ConsoleAttributes , , 0 , ()) \\\n _(UINT32 , PickerAttributes , , 0 , ()) \\\n _(OC_STRING , PickerVariant , , OC_STRING_CONSTR (\"Auto\", _, __) , OC_DESTR (OC_STRING)) \\\n _(UINT32 , TakeoffDelay , , 0 , ()) \\\n _(UINT32 , Timeout , , 0 , ()) \\\n _(BOOLEAN , PickerAudioAssist , , FALSE , ()) \\\n _(BOOLEAN , HideAuxiliary , , FALSE , ()) \\\n _(BOOLEAN , PollAppleHotKeys , , FALSE , ()) \\\n _(BOOLEAN , ShowPicker , , FALSE , ())\n OC_DECLARE (OC_MISC_BOOT)\n\n#define OC_MISC_DEBUG_FIELDS(_, __) \\\n _(UINT64 , DisplayLevel , , 0 , ()) \\\n _(UINT32 , DisplayDelay , , 0 , ()) \\\n _(UINT32 , Target , , 0 , ()) \\\n _(BOOLEAN , AppleDebug , , FALSE , ()) \\\n _(BOOLEAN , ApplePanic , , FALSE , ()) \\\n _(BOOLEAN , DisableWatchDog , , FALSE , ()) \\\n _(BOOLEAN , SerialInit , , FALSE , ()) \\\n _(BOOLEAN , SysReport , , FALSE , ())\n OC_DECLARE (OC_MISC_DEBUG)\n\n#define OCS_EXPOSE_BOOT_PATH 1U\n#define OCS_EXPOSE_VERSION_VAR 2U\n#define OCS_EXPOSE_VERSION_UI 4U\n#define OCS_EXPOSE_OEM_INFO 8U\n#define OCS_EXPOSE_VERSION (OCS_EXPOSE_VERSION_VAR | OCS_EXPOSE_VERSION_UI)\n#define OCS_EXPOSE_ALL_BITS (\\\n OCS_EXPOSE_BOOT_PATH | OCS_EXPOSE_VERSION_VAR | \\\n OCS_EXPOSE_VERSION_UI | OCS_EXPOSE_OEM_INFO)\n\ntypedef enum {\n OcsVaultOptional = 0,\n OcsVaultBasic = 1,\n OcsVaultSecure = 2,\n} OCS_VAULT_MODE;\n\n#define OC_MISC_SECURITY_FIELDS(_, __) \\\n _(OC_STRING , Vault , , OC_STRING_CONSTR (\"Secure\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , DmgLoading , , OC_STRING_CONSTR (\"Signed\", _, __), OC_DESTR (OC_STRING) ) \\\n _(UINT32 , ScanPolicy , , OC_SCAN_DEFAULT_POLICY , ()) \\\n _(UINT32 , ExposeSensitiveData , , OCS_EXPOSE_VERSION , ()) \\\n _(BOOLEAN , AllowNvramReset , , FALSE , ()) \\\n _(BOOLEAN , AllowSetDefault , , FALSE , ()) \\\n _(BOOLEAN , AllowToggleSip , , FALSE , ()) \\\n _(BOOLEAN , AuthRestart , , FALSE , ()) \\\n _(BOOLEAN , BlacklistAppleUpdate , , FALSE , ()) \\\n _(BOOLEAN , EnablePassword , , FALSE , ()) \\\n _(UINT8 , PasswordHash , [64] , {0} , ()) \\\n _(OC_DATA , PasswordSalt , , OC_EDATA_CONSTR (_, __) , OC_DESTR (OC_DATA)) \\\n _(OC_STRING , SecureBootModel , , OC_STRING_CONSTR (\"Default\", _, __), OC_DESTR (OC_STRING) ) \\\n _(UINT64 , ApECID , , 0 , ()) \\\n _(UINT64 , HaltLevel , , 0x80000000 , ())\n OC_DECLARE (OC_MISC_SECURITY)\n\n#define OC_MISC_TOOLS_ENTRY_FIELDS(_, __) \\\n _(OC_STRING , Arguments , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Comment , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Flavour , , OC_STRING_CONSTR (\"Auto\", _, __), OC_DESTR (OC_STRING) ) \\\n _(BOOLEAN , Auxiliary , , FALSE , () ) \\\n _(BOOLEAN , Enabled , , FALSE , () ) \\\n _(BOOLEAN , RealPath , , FALSE , () ) \\\n _(BOOLEAN , TextMode , , FALSE , () ) \\\n _(OC_STRING , Name , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Path , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) )\n OC_DECLARE (OC_MISC_TOOLS_ENTRY)\n\n#define OC_MISC_TOOLS_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_MISC_TOOLS_ENTRY, _, __)\n OC_DECLARE (OC_MISC_TOOLS_ARRAY)\n\n#define OC_MISC_CONFIG_FIELDS(_, __) \\\n _(OC_MISC_BLESS_ARRAY , BlessOverride , , OC_CONSTR2 (OC_MISC_BLESS_ARRAY, _, __) , OC_DESTR (OC_MISC_BLESS_ARRAY)) \\\n _(OC_MISC_BOOT , Boot , , OC_CONSTR2 (OC_MISC_BOOT, _, __) , OC_DESTR (OC_MISC_BOOT)) \\\n _(OC_MISC_DEBUG , Debug , , OC_CONSTR2 (OC_MISC_DEBUG, _, __) , OC_DESTR (OC_MISC_DEBUG)) \\\n _(OC_MISC_SECURITY , Security , , OC_CONSTR2 (OC_MISC_SECURITY, _, __) , OC_DESTR (OC_MISC_SECURITY)) \\\n _(OC_MISC_TOOLS_ARRAY , Entries , , OC_CONSTR2 (OC_MISC_TOOLS_ARRAY, _, __) , OC_DESTR (OC_MISC_TOOLS_ARRAY)) \\\n _(OC_MISC_TOOLS_ARRAY , Tools , , OC_CONSTR2 (OC_MISC_TOOLS_ARRAY, _, __) , OC_DESTR (OC_MISC_TOOLS_ARRAY))\n OC_DECLARE (OC_MISC_CONFIG)\n\n\/**\n NVRAM section\n**\/\n\n\/\/\/\n\/\/\/ NVRAM values is an associative map of GUIDS with their property key value maps.\n\/\/\/\n#define OC_NVRAM_ADD_MAP_FIELDS(_, __) \\\n OC_MAP (OC_STRING, OC_ASSOC, _, __)\n OC_DECLARE (OC_NVRAM_ADD_MAP)\n\n#define OC_NVRAM_DELETE_ENTRY_FIELDS(_, __) \\\n OC_ARRAY (OC_STRING, _, __)\n OC_DECLARE (OC_NVRAM_DELETE_ENTRY)\n\n#define OC_NVRAM_DELETE_MAP_FIELDS(_, __) \\\n OC_MAP (OC_STRING, OC_NVRAM_DELETE_ENTRY, _, __)\n OC_DECLARE (OC_NVRAM_DELETE_MAP)\n\n#define OC_NVRAM_LEGACY_ENTRY_FIELDS(_, __) \\\n OC_ARRAY (OC_STRING, _, __)\n OC_DECLARE (OC_NVRAM_LEGACY_ENTRY)\n\n#define OC_NVRAM_LEGACY_MAP_FIELDS(_, __) \\\n OC_MAP (OC_STRING, OC_NVRAM_LEGACY_ENTRY, _, __)\n OC_DECLARE (OC_NVRAM_LEGACY_MAP)\n\n#define OC_NVRAM_CONFIG_FIELDS(_, __) \\\n _(OC_NVRAM_ADD_MAP , Add , , OC_CONSTR2 (OC_NVRAM_ADD_MAP, _, __) , OC_DESTR (OC_NVRAM_ADD_MAP)) \\\n _(OC_NVRAM_DELETE_MAP , Delete , , OC_CONSTR2 (OC_NVRAM_DELETE_MAP, _, __) , OC_DESTR (OC_NVRAM_DELETE_MAP)) \\\n _(OC_NVRAM_LEGACY_MAP , Legacy , , OC_CONSTR2 (OC_NVRAM_LEGACY_MAP, _, __) , OC_DESTR (OC_NVRAM_LEGACY_MAP)) \\\n _(BOOLEAN , LegacyEnable , , FALSE , () ) \\\n _(BOOLEAN , LegacyOverwrite , , FALSE , () ) \\\n _(BOOLEAN , WriteFlash , , FALSE , () )\n OC_DECLARE (OC_NVRAM_CONFIG)\n\n\/**\n Platform information configuration\n**\/\n\n#define OC_PLATFORM_GENERIC_CONFIG_FIELDS(_, __) \\\n _(OC_STRING , SystemProductName , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemSerialNumber , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemUuid , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Mlb , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemMemoryStatus , , OC_STRING_CONSTR (\"Auto\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(UINT16 , ProcessorType , , 0 , () ) \\\n _(UINT8 , Rom , [6] , {0} , () ) \\\n _(BOOLEAN , SpoofVendor , , FALSE , () ) \\\n _(BOOLEAN , AdviseFeatures , , FALSE , () ) \\\n _(BOOLEAN , MaxBIOSVersion , , FALSE , () )\n OC_DECLARE (OC_PLATFORM_GENERIC_CONFIG)\n\n#define OC_PLATFORM_DATA_HUB_CONFIG_FIELDS(_, __) \\\n _(OC_STRING , PlatformName , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemProductName , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemSerialNumber , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemUuid , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , BoardProduct , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(UINT8 , BoardRevision , [1] , {0} , () ) \\\n _(UINT64 , StartupPowerEvents , , 0 , () ) \\\n _(UINT64 , InitialTSC , , 0 , () ) \\\n _(UINT64 , FSBFrequency , , 0 , () ) \\\n _(UINT64 , ARTFrequency , , 0 , () ) \\\n _(UINT32 , DevicePathsSupported, , 0 , () ) \\\n _(UINT8 , SmcRevision , [6] , {0} , () ) \\\n _(UINT8 , SmcBranch , [8] , {0} , () ) \\\n _(UINT8 , SmcPlatform , [8] , {0} , () )\n OC_DECLARE (OC_PLATFORM_DATA_HUB_CONFIG)\n\n#define OC_PLATFORM_MEMORY_DEVICE_ENTRY_FIELDS(_, __) \\\n _(UINT32 , Size , , 0 , () ) \\\n _(UINT16 , Speed , , 0 , () ) \\\n _(OC_STRING , DeviceLocator , , OC_STRING_CONSTR (\"Unknown\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , BankLocator , , OC_STRING_CONSTR (\"Unknown\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Manufacturer , , OC_STRING_CONSTR (\"Unknown\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SerialNumber , , OC_STRING_CONSTR (\"Unknown\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , AssetTag , , OC_STRING_CONSTR (\"Unknown\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , PartNumber , , OC_STRING_CONSTR (\"Unknown\", _, __), OC_DESTR (OC_STRING) )\n OC_DECLARE (OC_PLATFORM_MEMORY_DEVICE_ENTRY)\n\n#define OC_PLATFORM_MEMORY_DEVICES_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_PLATFORM_MEMORY_DEVICE_ENTRY, _, __)\n OC_DECLARE (OC_PLATFORM_MEMORY_DEVICES_ARRAY)\n\n#define OC_PLATFORM_MEMORY_CONFIG_FIELDS(_, __) \\\n _(UINT8 , FormFactor , , 0x2 , () ) \\\n _(UINT8 , Type , , 0x2 , () ) \\\n _(UINT16 , TypeDetail , , 0x4 , () ) \\\n _(UINT16 , TotalWidth , , 0xFFFF , () ) \\\n _(UINT16 , DataWidth , , 0xFFFF , () ) \\\n _(UINT8 , ErrorCorrection, , 0x3 , () ) \\\n _(UINT64 , MaxCapacity , , 0 , () ) \\\n _(OC_PLATFORM_MEMORY_DEVICES_ARRAY, Devices , , OC_CONSTR3 (OC_PLATFORM_MEMORY_DEVICES_ARRAY, _, __), OC_DESTR (OC_PLATFORM_MEMORY_DEVICES_ARRAY))\n OC_DECLARE (OC_PLATFORM_MEMORY_CONFIG)\n\n#define OC_PLATFORM_NVRAM_CONFIG_FIELDS(_, __) \\\n _(OC_STRING , Bid , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Mlb , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemSerialNumber , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemUuid , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(UINT8 , Rom , [6] , {0} , () ) \\\n _(UINT64 , FirmwareFeatures , , 0 , () ) \\\n _(UINT64 , FirmwareFeaturesMask , , 0 , () )\n OC_DECLARE (OC_PLATFORM_NVRAM_CONFIG)\n\n#define OC_PLATFORM_SMBIOS_CONFIG_FIELDS(_, __) \\\n _(OC_STRING , BIOSVendor , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , BIOSVersion , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , BIOSReleaseDate , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemManufacturer , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemProductName , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemVersion , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemSerialNumber , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemUuid , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemSKUNumber , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , SystemFamily , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , BoardManufacturer , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , BoardProduct , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , BoardVersion , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , BoardSerialNumber , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , BoardAssetTag , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(UINT8 , BoardType , , 0 , () ) \\\n _(OC_STRING , BoardLocationInChassis, , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , ChassisManufacturer , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(UINT8 , ChassisType , , 0 , () ) \\\n _(OC_STRING , ChassisVersion , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , ChassisSerialNumber , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , ChassisAssetTag , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(UINT32 , PlatformFeature , , 0xFFFFFFFFU , () ) \\\n _(UINT64 , FirmwareFeatures , , 0 , () ) \\\n _(UINT64 , FirmwareFeaturesMask , , 0 , () ) \\\n _(UINT8 , SmcVersion , [16] , {0} , () ) \\\n _(UINT16 , ProcessorType , , 0 , () )\n OC_DECLARE (OC_PLATFORM_SMBIOS_CONFIG)\n\n#define OC_PLATFORM_CONFIG_FIELDS(_, __) \\\n _(BOOLEAN , Automatic , , FALSE , ()) \\\n _(BOOLEAN , CustomMemory , , FALSE , ()) \\\n _(BOOLEAN , UpdateDataHub , , FALSE , ()) \\\n _(BOOLEAN , UpdateNvram , , FALSE , ()) \\\n _(BOOLEAN , UpdateSmbios , , FALSE , ()) \\\n _(BOOLEAN , UseRawUuidEncoding , , FALSE , ()) \\\n _(OC_STRING , UpdateSmbiosMode , , OC_STRING_CONSTR (\"Create\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_PLATFORM_GENERIC_CONFIG , Generic , , OC_CONSTR2 (OC_PLATFORM_GENERIC_CONFIG, _, __) , OC_DESTR (OC_PLATFORM_GENERIC_CONFIG)) \\\n _(OC_PLATFORM_DATA_HUB_CONFIG , DataHub , , OC_CONSTR2 (OC_PLATFORM_DATA_HUB_CONFIG, _, __) , OC_DESTR (OC_PLATFORM_DATA_HUB_CONFIG)) \\\n _(OC_PLATFORM_MEMORY_CONFIG , Memory , , OC_CONSTR2 (OC_PLATFORM_MEMORY_CONFIG, _, __) , OC_DESTR (OC_PLATFORM_MEMORY_CONFIG)) \\\n _(OC_PLATFORM_NVRAM_CONFIG , Nvram , , OC_CONSTR2 (OC_PLATFORM_NVRAM_CONFIG, _, __) , OC_DESTR (OC_PLATFORM_NVRAM_CONFIG)) \\\n _(OC_PLATFORM_SMBIOS_CONFIG , Smbios , , OC_CONSTR2 (OC_PLATFORM_SMBIOS_CONFIG, _, __) , OC_DESTR (OC_PLATFORM_SMBIOS_CONFIG))\n OC_DECLARE (OC_PLATFORM_CONFIG)\n\n\n\/**\n Uefi section\n**\/\n\n\/\/\/\n\/\/\/ Drivers is an ordered array of drivers to load.\n\/\/\/\n#define OC_UEFI_DRIVER_ENTRY_FIELDS(_, __) \\\n _(OC_STRING , Arguments , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Comment , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(BOOLEAN , Enabled , , FALSE , ()) \\\n _(OC_STRING , Path , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING) )\n OC_DECLARE (OC_UEFI_DRIVER_ENTRY)\n\n#define OC_UEFI_DRIVER_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_UEFI_DRIVER_ENTRY, _, __)\n OC_DECLARE (OC_UEFI_DRIVER_ARRAY)\n\n\/\/\/\n\/\/\/ APFS is a set of options for APFS file system support.\n\/\/\/\n#define OC_UEFI_APFS_FIELDS(_, __) \\\n _(UINT64 , MinVersion , , 0 , ()) \\\n _(UINT32 , MinDate , , 0 , ()) \\\n _(BOOLEAN , EnableJumpstart , , FALSE , ()) \\\n _(BOOLEAN , GlobalConnect , , FALSE , ()) \\\n _(BOOLEAN , HideVerbose , , FALSE , ()) \\\n _(BOOLEAN , JumpstartHotPlug , , FALSE , ())\n OC_DECLARE (OC_UEFI_APFS)\n\n\/\/\/\n\/\/\/ AppleInput is a set of options to configure OpenCore's reverse engingeered then customised implementation of the AppleEvent protocol.\n\/\/\/\n#define OC_UEFI_APPLEINPUT_FIELDS(_, __) \\\n _(OC_STRING , AppleEvent , , OC_STRING_CONSTR (\"Auto\", _, __) , OC_DESTR (OC_STRING) ) \\\n _(BOOLEAN , CustomDelays , , FALSE , ()) \\\n _(UINT16 , KeyInitialDelay , , 50 , ()) \\\n _(UINT16 , KeySubsequentDelay , , 5 , ()) \\\n _(BOOLEAN , GraphicsInputMirroring, , FALSE , ()) \\\n _(UINT16 , PointerSpeedDiv , , 1 , ()) \\\n _(UINT16 , PointerSpeedMul , , 1 , ())\n OC_DECLARE (OC_UEFI_APPLEINPUT)\n\n\/\/\/\n\/\/\/ Audio is a set of options for sound configuration.\n\/\/\/\n#define OC_UEFI_AUDIO_FIELDS(_, __) \\\n _(OC_STRING , AudioDevice , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING)) \\\n _(OC_STRING , PlayChime , , OC_STRING_CONSTR (\"Auto\", _, __) , OC_DESTR (OC_STRING)) \\\n _(UINT32 , SetupDelay , , 0 , ()) \\\n _(UINT16 , VolumeAmplifier , , 0 , ()) \\\n _(BOOLEAN , AudioSupport , , FALSE , ()) \\\n _(UINT8 , AudioCodec , , 0 , ()) \\\n _(UINT8 , AudioOut , , 0 , ()) \\\n _(UINT8 , MinimumVolume , , 0 , ()) \\\n _(BOOLEAN , ResetTrafficClass , , FALSE , ())\n OC_DECLARE (OC_UEFI_AUDIO)\n\n\/\/\/\n\/\/\/ Input is a set of options to support advanced input.\n\/\/\/\n#define OC_UEFI_INPUT_FIELDS(_, __) \\\n _(OC_STRING , KeySupportMode , , OC_STRING_CONSTR (\"Auto\", _, __) , OC_DESTR (OC_STRING)) \\\n _(OC_STRING , PointerSupportMode , , OC_STRING_CONSTR (\"\", _, __) , OC_DESTR (OC_STRING)) \\\n _(UINT32 , TimerResolution , , 0 , ()) \\\n _(UINT8 , KeyForgetThreshold , , 0 , ()) \\\n _(BOOLEAN , KeySupport , , FALSE , ()) \\\n _(BOOLEAN , KeyFiltering , , FALSE , ()) \\\n _(BOOLEAN , KeySwap , , FALSE , ()) \\\n _(BOOLEAN , PointerSupport , , FALSE , ())\n OC_DECLARE (OC_UEFI_INPUT)\n\n\/\/\/\n\/\/\/ Output is a set of options to support advanced output.\n\/\/\/\n#define OC_UEFI_OUTPUT_FIELDS(_, __) \\\n _(OC_STRING , ConsoleMode , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING)) \\\n _(OC_STRING , Resolution , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING)) \\\n _(OC_STRING , TextRenderer , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING)) \\\n _(OC_STRING , GopPassThrough , , OC_STRING_CONSTR (\"Disabled\", _, __), OC_DESTR (OC_STRING)) \\\n _(BOOLEAN , IgnoreTextInGraphics , , FALSE , ()) \\\n _(BOOLEAN , ClearScreenOnModeSwitch , , FALSE , ()) \\\n _(BOOLEAN , ProvideConsoleGop , , FALSE , ()) \\\n _(BOOLEAN , ReplaceTabWithSpace , , FALSE , ()) \\\n _(BOOLEAN , ReconnectOnResChange , , FALSE , ()) \\\n _(BOOLEAN , SanitiseClearScreen , , FALSE , ()) \\\n _(BOOLEAN , UgaPassThrough , , FALSE , ()) \\\n _(BOOLEAN , DirectGopRendering , , FALSE , ()) \\\n _(BOOLEAN , ForceResolution , , FALSE , ())\n OC_DECLARE (OC_UEFI_OUTPUT)\n\n\/\/\/\n\/\/\/ Prefer own protocol implementation for these protocols.\n\/\/\/\n#define OC_UEFI_PROTOCOL_OVERRIDES_FIELDS(_, __) \\\n _(BOOLEAN , AppleAudio , , FALSE , ()) \\\n _(BOOLEAN , AppleBootPolicy , , FALSE , ()) \\\n _(BOOLEAN , AppleDebugLog , , FALSE , ()) \\\n _(BOOLEAN , AppleEg2Info , , FALSE , ()) \\\n _(BOOLEAN , AppleFramebufferInfo , , FALSE , ()) \\\n _(BOOLEAN , AppleImageConversion , , FALSE , ()) \\\n _(BOOLEAN , AppleImg4Verification , , FALSE , ()) \\\n _(BOOLEAN , AppleKeyMap , , FALSE , ()) \\\n _(BOOLEAN , AppleRtcRam , , FALSE , ()) \\\n _(BOOLEAN , AppleSecureBoot , , FALSE , ()) \\\n _(BOOLEAN , AppleSmcIo , , FALSE , ()) \\\n _(BOOLEAN , AppleUserInterfaceTheme , , FALSE , ()) \\\n _(BOOLEAN , DataHub , , FALSE , ()) \\\n _(BOOLEAN , DeviceProperties , , FALSE , ()) \\\n _(BOOLEAN , FirmwareVolume , , FALSE , ()) \\\n _(BOOLEAN , HashServices , , FALSE , ()) \\\n _(BOOLEAN , OSInfo , , FALSE , ()) \\\n _(BOOLEAN , UnicodeCollation , , FALSE , ())\n OC_DECLARE (OC_UEFI_PROTOCOL_OVERRIDES)\n\n\/\/\/\n\/\/\/ Quirks is a set of hacks for different types of firmware.\n\/\/\/\n#define OC_UEFI_QUIRKS_FIELDS(_, __) \\\n _(UINT32 , ExitBootServicesDelay , , 0 , ()) \\\n _(UINT32 , TscSyncTimeout , , 0 , ()) \\\n _(BOOLEAN , ActivateHpetSupport , , FALSE , ()) \\\n _(BOOLEAN , DisableSecurityPolicy , , FALSE , ()) \\\n _(BOOLEAN , EnableVectorAcceleration , , FALSE , ()) \\\n _(BOOLEAN , ForgeUefiSupport , , FALSE , ()) \\\n _(BOOLEAN , IgnoreInvalidFlexRatio , , FALSE , ()) \\\n _(BOOLEAN , ReleaseUsbOwnership , , FALSE , ()) \\\n _(BOOLEAN , ReloadOptionRoms , , FALSE , ()) \\\n _(BOOLEAN , RequestBootVarRouting , , FALSE , ()) \\\n _(BOOLEAN , UnblockFsConnect , , FALSE , ()) \\\n _(BOOLEAN , ForceOcWriteFlash , , FALSE , ())\n OC_DECLARE (OC_UEFI_QUIRKS)\n\n\/\/\/\n\/\/\/ Reserved memory entries adds.\n\/\/\/\n#define OC_UEFI_RSVD_ENTRY_FIELDS(_, __) \\\n _(UINT64 , Address , , 0 , () ) \\\n _(UINT64 , Size , , 0 , () ) \\\n _(BOOLEAN , Enabled , , FALSE , () ) \\\n _(OC_STRING , Type , , OC_STRING_CONSTR (\"Reserved\", _, __), OC_DESTR (OC_STRING) ) \\\n _(OC_STRING , Comment , , OC_STRING_CONSTR (\"\", _, __), OC_DESTR (OC_STRING) )\n OC_DECLARE (OC_UEFI_RSVD_ENTRY)\n\n#define OC_UEFI_RSVD_ARRAY_FIELDS(_, __) \\\n OC_ARRAY (OC_UEFI_RSVD_ENTRY, _, __)\n OC_DECLARE (OC_UEFI_RSVD_ARRAY)\n\n\/\/\/\n\/\/\/ Uefi contains firmware tweaks and extra drivers.\n\/\/\/\n#define OC_UEFI_CONFIG_FIELDS(_, __) \\\n _(BOOLEAN , ConnectDrivers , , FALSE , ()) \\\n _(OC_UEFI_APFS , Apfs , , OC_CONSTR2 (OC_UEFI_APFS, _, __) , OC_DESTR (OC_UEFI_APFS)) \\\n _(OC_UEFI_APPLEINPUT , AppleInput , , OC_CONSTR2 (OC_UEFI_APPLEINPUT, _, __) , OC_DESTR (OC_UEFI_APPLEINPUT)) \\\n _(OC_UEFI_AUDIO , Audio , , OC_CONSTR2 (OC_UEFI_AUDIO, _, __) , OC_DESTR (OC_UEFI_AUDIO)) \\\n _(OC_UEFI_DRIVER_ARRAY , Drivers , , OC_CONSTR2 (OC_UEFI_DRIVER_ARRAY, _, __) , OC_DESTR (OC_UEFI_DRIVER_ARRAY)) \\\n _(OC_UEFI_INPUT , Input , , OC_CONSTR2 (OC_UEFI_INPUT, _, __) , OC_DESTR (OC_UEFI_INPUT)) \\\n _(OC_UEFI_OUTPUT , Output , , OC_CONSTR2 (OC_UEFI_OUTPUT, _, __) , OC_DESTR (OC_UEFI_OUTPUT)) \\\n _(OC_UEFI_PROTOCOL_OVERRIDES , ProtocolOverrides , , OC_CONSTR2 (OC_UEFI_PROTOCOL_OVERRIDES, _, __) , OC_DESTR (OC_UEFI_PROTOCOL_OVERRIDES)) \\\n _(OC_UEFI_QUIRKS , Quirks , , OC_CONSTR2 (OC_UEFI_QUIRKS, _, __) , OC_DESTR (OC_UEFI_QUIRKS)) \\\n _(OC_UEFI_RSVD_ARRAY , ReservedMemory , , OC_CONSTR2 (OC_UEFI_RSVD_ARRAY, _, __) , OC_DESTR (OC_UEFI_RSVD_ARRAY))\n OC_DECLARE (OC_UEFI_CONFIG)\n\n\/**\n Root configuration\n**\/\n\n#define OC_GLOBAL_CONFIG_FIELDS(_, __) \\\n _(OC_ACPI_CONFIG , Acpi , , OC_CONSTR1 (OC_ACPI_CONFIG, _, __) , OC_DESTR (OC_ACPI_CONFIG)) \\\n _(OC_BOOTER_CONFIG , Booter , , OC_CONSTR1 (OC_BOOTER_CONFIG, _, __) , OC_DESTR (OC_BOOTER_CONFIG)) \\\n _(OC_DEV_PROP_CONFIG , DeviceProperties , , OC_CONSTR1 (OC_DEV_PROP_CONFIG, _, __) , OC_DESTR (OC_DEV_PROP_CONFIG)) \\\n _(OC_KERNEL_CONFIG , Kernel , , OC_CONSTR1 (OC_KERNEL_CONFIG, _, __) , OC_DESTR (OC_KERNEL_CONFIG)) \\\n _(OC_MISC_CONFIG , Misc , , OC_CONSTR1 (OC_MISC_CONFIG, _, __) , OC_DESTR (OC_MISC_CONFIG)) \\\n _(OC_NVRAM_CONFIG , Nvram , , OC_CONSTR1 (OC_NVRAM_CONFIG, _, __) , OC_DESTR (OC_NVRAM_CONFIG)) \\\n _(OC_PLATFORM_CONFIG , PlatformInfo , , OC_CONSTR1 (OC_PLATFORM_CONFIG, _, __) , OC_DESTR (OC_PLATFORM_CONFIG)) \\\n _(OC_UEFI_CONFIG , Uefi , , OC_CONSTR1 (OC_UEFI_CONFIG, _, __) , OC_DESTR (OC_UEFI_CONFIG))\n OC_DECLARE (OC_GLOBAL_CONFIG)\n\n\/**\n Initialize configuration with plist data.\n\n @param[out] Config Configuration structure.\n @param[in] Buffer Configuration buffer in plist format.\n @param[in] Size Configuration buffer size.\n @param[in,out] ErrorCount Errors detected duing initialisation. Optional.\n\n @retval EFI_SUCCESS on success\n**\/\nEFI_STATUS\nOcConfigurationInit (\n OUT OC_GLOBAL_CONFIG *Config,\n IN VOID *Buffer,\n IN UINT32 Size,\n IN OUT UINT32 *ErrorCount OPTIONAL\n );\n\n\/**\n Free configuration structure.\n\n @param[in,out] Config Configuration structure.\n**\/\nVOID\nOcConfigurationFree (\n IN OUT OC_GLOBAL_CONFIG *Config\n );\n\n#endif \/\/ OC_CONFIGURATION_LIB_H\n","avg_line_length":66.7961290323,"max_line_length":159,"alphanum_fraction":0.4456120695} +{"size":2144,"ext":"h","lang":"C","max_stars_count":60067.0,"content":"#ifndef CAFFE2_CORE_NET_PARALLEL_H\n#define CAFFE2_CORE_NET_PARALLEL_H\n\n#include \"caffe2\/core\/net_async_base.h\"\n#include \"caffe2\/core\/net_async_task_graph.h\"\n\nC10_DECLARE_string(caffe2_task_graph_engine);\n\nnamespace caffe2 {\n\nclass ParallelNetExecutorHelper;\n\nclass TORCH_API ParallelNet : public NetBase {\n public:\n ParallelNet(const std::shared_ptr& net_def, Workspace* ws);\n\n bool RunAsync() override;\n void Wait() override;\n\n bool SupportsAsync() override;\n std::vector GetOperators() const override;\n\n TaskThreadPoolBase* Pool(const DeviceOption& device_option);\n\n protected:\n bool handleRunError() override;\n virtual void finishRun();\n virtual void reset();\n\n ExecutionOptions options_;\n int num_workers_;\n\n std::unique_ptr helper_;\n std::shared_ptr task_graph_;\n AsyncTaskFuture* run_future_;\n\n std::vector operator_nodes_;\n std::vector operators_;\n\n std::mutex pools_mutex_;\n typedef std::unordered_map<\n int,\n std::unordered_map>>\n PoolsMap;\n PoolsMap cpu_pools_;\n PoolsMap gpu_pools_;\n TaskThreadPoolBase*\n poolGetter(PoolsMap& pools, int device_type, int device_id, int pool_size);\n\n friend class ParallelNetExecutorHelper;\n C10_DISABLE_COPY_AND_ASSIGN(ParallelNet);\n};\n\nC10_DECLARE_SHARED_REGISTRY(\n TaskGraphRegistry,\n AsyncTaskGraphBase,\n ExecutorHelper*,\n const ExecutionOptions&);\n\nstd::shared_ptr GetAsyncTaskGraph(\n ExecutorHelper* helper,\n const ExecutionOptions& options);\n\nclass ParallelNetExecutorHelper : public ExecutorHelper {\n public:\n explicit ParallelNetExecutorHelper(ParallelNet* net) : net_(net) {}\n TaskThreadPoolBase* GetPool(const DeviceOption& option) const override {\n return net_->Pool(option);\n }\n\n std::vector GetOperators() const override {\n return net_->GetOperators();\n }\n\n int GetNumWorkers() const override {\n return net_->num_workers_;\n }\n\n private:\n ParallelNet* net_;\n};\n\n} \/\/ namespace caffe2\n\n#endif \/\/ CAFFE2_CORE_NET_PARALLEL_H\n","avg_line_length":24.9302325581,"max_line_length":77,"alphanum_fraction":0.7672574627} +{"size":63842,"ext":"c","lang":"C","max_stars_count":null,"content":"\n#include \"upb\/def.h\"\n\n#include \n#include \n#include \n#include \n#include \n\n#include \"google\/protobuf\/descriptor.upb.h\"\n#include \"upb\/port_def.inc\"\n\ntypedef struct {\n size_t len;\n char str[1]; \/* Null-terminated string data follows. *\/\n} str_t;\n\nstruct upb_fielddef {\n const upb_filedef *file;\n const upb_msgdef *msgdef;\n const char *full_name;\n const char *json_name;\n union {\n int64_t sint;\n uint64_t uint;\n double dbl;\n float flt;\n bool boolean;\n str_t *str;\n } defaultval;\n const upb_oneofdef *oneof;\n union {\n const upb_msgdef *msgdef;\n const upb_enumdef *enumdef;\n const google_protobuf_FieldDescriptorProto *unresolved;\n } sub;\n uint32_t number_;\n uint16_t index_;\n uint16_t layout_index;\n uint32_t selector_base; \/* Used to index into a upb::Handlers table. *\/\n bool is_extension_;\n bool lazy_;\n bool packed_;\n bool proto3_optional_;\n upb_descriptortype_t type_;\n upb_label_t label_;\n};\n\nstruct upb_msgdef {\n const upb_msglayout *layout;\n const upb_filedef *file;\n const char *full_name;\n uint32_t selector_count;\n uint32_t submsg_field_count;\n\n \/* Tables for looking up fields by number and name. *\/\n upb_inttable itof;\n upb_strtable ntof;\n\n const upb_fielddef *fields;\n const upb_oneofdef *oneofs;\n int field_count;\n int oneof_count;\n int real_oneof_count;\n\n \/* Is this a map-entry message? *\/\n bool map_entry;\n upb_wellknowntype_t well_known_type;\n\n \/* TODO(haberman): proper extension ranges (there can be multiple). *\/\n};\n\nstruct upb_enumdef {\n const upb_filedef *file;\n const char *full_name;\n upb_strtable ntoi;\n upb_inttable iton;\n int32_t defaultval;\n};\n\nstruct upb_oneofdef {\n const upb_msgdef *parent;\n const char *full_name;\n int field_count;\n bool synthetic;\n const upb_fielddef **fields;\n upb_strtable ntof;\n upb_inttable itof;\n};\n\nstruct upb_filedef {\n const char *name;\n const char *package;\n const char *phpprefix;\n const char *phpnamespace;\n upb_syntax_t syntax;\n\n const upb_filedef **deps;\n const upb_msgdef *msgs;\n const upb_enumdef *enums;\n const upb_fielddef *exts;\n\n int dep_count;\n int msg_count;\n int enum_count;\n int ext_count;\n};\n\nstruct upb_symtab {\n upb_arena *arena;\n upb_strtable syms; \/* full_name -> packed def ptr *\/\n upb_strtable files; \/* file_name -> upb_filedef* *\/\n size_t bytes_loaded;\n};\n\n\/* Inside a symtab we store tagged pointers to specific def types. *\/\ntypedef enum {\n UPB_DEFTYPE_FIELD = 0,\n\n \/* Only inside symtab table. *\/\n UPB_DEFTYPE_MSG = 1,\n UPB_DEFTYPE_ENUM = 2,\n\n \/* Only inside message table. *\/\n UPB_DEFTYPE_ONEOF = 1,\n UPB_DEFTYPE_FIELD_JSONNAME = 2\n} upb_deftype_t;\n\nstatic const void *unpack_def(upb_value v, upb_deftype_t type) {\n uintptr_t num = (uintptr_t)upb_value_getconstptr(v);\n return (num & 3) == type ? (const void*)(num & ~3) : NULL;\n}\n\nstatic upb_value pack_def(const void *ptr, upb_deftype_t type) {\n uintptr_t num = (uintptr_t)ptr | type;\n return upb_value_constptr((const void*)num);\n}\n\n\/* isalpha() etc. from are locale-dependent, which we don't want. *\/\nstatic bool upb_isbetween(char c, char low, char high) {\n return c >= low && c <= high;\n}\n\nstatic bool upb_isletter(char c) {\n return upb_isbetween(c, 'A', 'Z') || upb_isbetween(c, 'a', 'z') || c == '_';\n}\n\nstatic bool upb_isalphanum(char c) {\n return upb_isletter(c) || upb_isbetween(c, '0', '9');\n}\n\nstatic const char *shortdefname(const char *fullname) {\n const char *p;\n\n if (fullname == NULL) {\n return NULL;\n } else if ((p = strrchr(fullname, '.')) == NULL) {\n \/* No '.' in the name, return the full string. *\/\n return fullname;\n } else {\n \/* Return one past the last '.'. *\/\n return p + 1;\n }\n}\n\n\/* All submessage fields are lower than all other fields.\n * Secondly, fields are increasing in order. *\/\nuint32_t field_rank(const upb_fielddef *f) {\n uint32_t ret = upb_fielddef_number(f);\n const uint32_t high_bit = 1 << 30;\n UPB_ASSERT(ret < high_bit);\n if (!upb_fielddef_issubmsg(f))\n ret |= high_bit;\n return ret;\n}\n\nint cmp_fields(const void *p1, const void *p2) {\n const upb_fielddef *f1 = *(upb_fielddef*const*)p1;\n const upb_fielddef *f2 = *(upb_fielddef*const*)p2;\n return field_rank(f1) - field_rank(f2);\n}\n\n\/* A few implementation details of handlers. We put these here to avoid\n * a def -> handlers dependency. *\/\n\n#define UPB_STATIC_SELECTOR_COUNT 3 \/* Warning: also in upb\/handlers.h. *\/\n\nstatic uint32_t upb_handlers_selectorbaseoffset(const upb_fielddef *f) {\n return upb_fielddef_isseq(f) ? 2 : 0;\n}\n\nstatic uint32_t upb_handlers_selectorcount(const upb_fielddef *f) {\n uint32_t ret = 1;\n if (upb_fielddef_isseq(f)) ret += 2; \/* STARTSEQ\/ENDSEQ *\/\n if (upb_fielddef_isstring(f)) ret += 2; \/* [STRING]\/STARTSTR\/ENDSTR *\/\n if (upb_fielddef_issubmsg(f)) {\n \/* ENDSUBMSG (STARTSUBMSG is at table beginning) *\/\n ret += 0;\n if (upb_fielddef_lazy(f)) {\n \/* STARTSTR\/ENDSTR\/STRING (for lazy) *\/\n ret += 3;\n }\n }\n return ret;\n}\n\nstatic void upb_status_setoom(upb_status *status) {\n upb_status_seterrmsg(status, \"out of memory\");\n}\n\nstatic void assign_msg_wellknowntype(upb_msgdef *m) {\n const char *name = upb_msgdef_fullname(m);\n if (name == NULL) {\n m->well_known_type = UPB_WELLKNOWN_UNSPECIFIED;\n return;\n }\n if (!strcmp(name, \"google.protobuf.Any\")) {\n m->well_known_type = UPB_WELLKNOWN_ANY;\n } else if (!strcmp(name, \"google.protobuf.FieldMask\")) {\n m->well_known_type = UPB_WELLKNOWN_FIELDMASK;\n } else if (!strcmp(name, \"google.protobuf.Duration\")) {\n m->well_known_type = UPB_WELLKNOWN_DURATION;\n } else if (!strcmp(name, \"google.protobuf.Timestamp\")) {\n m->well_known_type = UPB_WELLKNOWN_TIMESTAMP;\n } else if (!strcmp(name, \"google.protobuf.DoubleValue\")) {\n m->well_known_type = UPB_WELLKNOWN_DOUBLEVALUE;\n } else if (!strcmp(name, \"google.protobuf.FloatValue\")) {\n m->well_known_type = UPB_WELLKNOWN_FLOATVALUE;\n } else if (!strcmp(name, \"google.protobuf.Int64Value\")) {\n m->well_known_type = UPB_WELLKNOWN_INT64VALUE;\n } else if (!strcmp(name, \"google.protobuf.UInt64Value\")) {\n m->well_known_type = UPB_WELLKNOWN_UINT64VALUE;\n } else if (!strcmp(name, \"google.protobuf.Int32Value\")) {\n m->well_known_type = UPB_WELLKNOWN_INT32VALUE;\n } else if (!strcmp(name, \"google.protobuf.UInt32Value\")) {\n m->well_known_type = UPB_WELLKNOWN_UINT32VALUE;\n } else if (!strcmp(name, \"google.protobuf.BoolValue\")) {\n m->well_known_type = UPB_WELLKNOWN_BOOLVALUE;\n } else if (!strcmp(name, \"google.protobuf.StringValue\")) {\n m->well_known_type = UPB_WELLKNOWN_STRINGVALUE;\n } else if (!strcmp(name, \"google.protobuf.BytesValue\")) {\n m->well_known_type = UPB_WELLKNOWN_BYTESVALUE;\n } else if (!strcmp(name, \"google.protobuf.Value\")) {\n m->well_known_type = UPB_WELLKNOWN_VALUE;\n } else if (!strcmp(name, \"google.protobuf.ListValue\")) {\n m->well_known_type = UPB_WELLKNOWN_LISTVALUE;\n } else if (!strcmp(name, \"google.protobuf.Struct\")) {\n m->well_known_type = UPB_WELLKNOWN_STRUCT;\n } else {\n m->well_known_type = UPB_WELLKNOWN_UNSPECIFIED;\n }\n}\n\n\n\/* upb_enumdef ****************************************************************\/\n\nconst char *upb_enumdef_fullname(const upb_enumdef *e) {\n return e->full_name;\n}\n\nconst char *upb_enumdef_name(const upb_enumdef *e) {\n return shortdefname(e->full_name);\n}\n\nconst upb_filedef *upb_enumdef_file(const upb_enumdef *e) {\n return e->file;\n}\n\nint32_t upb_enumdef_default(const upb_enumdef *e) {\n UPB_ASSERT(upb_enumdef_iton(e, e->defaultval));\n return e->defaultval;\n}\n\nint upb_enumdef_numvals(const upb_enumdef *e) {\n return (int)upb_strtable_count(&e->ntoi);\n}\n\nvoid upb_enum_begin(upb_enum_iter *i, const upb_enumdef *e) {\n \/* We iterate over the ntoi table, to account for duplicate numbers. *\/\n upb_strtable_begin(i, &e->ntoi);\n}\n\nvoid upb_enum_next(upb_enum_iter *iter) { upb_strtable_next(iter); }\nbool upb_enum_done(upb_enum_iter *iter) { return upb_strtable_done(iter); }\n\nbool upb_enumdef_ntoi(const upb_enumdef *def, const char *name,\n size_t len, int32_t *num) {\n upb_value v;\n if (!upb_strtable_lookup2(&def->ntoi, name, len, &v)) {\n return false;\n }\n if (num) *num = upb_value_getint32(v);\n return true;\n}\n\nconst char *upb_enumdef_iton(const upb_enumdef *def, int32_t num) {\n upb_value v;\n return upb_inttable_lookup32(&def->iton, num, &v) ?\n upb_value_getcstr(v) : NULL;\n}\n\nconst char *upb_enum_iter_name(upb_enum_iter *iter) {\n return upb_strtable_iter_key(iter).data;\n}\n\nint32_t upb_enum_iter_number(upb_enum_iter *iter) {\n return upb_value_getint32(upb_strtable_iter_value(iter));\n}\n\n\n\/* upb_fielddef ***************************************************************\/\n\nconst char *upb_fielddef_fullname(const upb_fielddef *f) {\n return f->full_name;\n}\n\nupb_fieldtype_t upb_fielddef_type(const upb_fielddef *f) {\n switch (f->type_) {\n case UPB_DESCRIPTOR_TYPE_DOUBLE:\n return UPB_TYPE_DOUBLE;\n case UPB_DESCRIPTOR_TYPE_FLOAT:\n return UPB_TYPE_FLOAT;\n case UPB_DESCRIPTOR_TYPE_INT64:\n case UPB_DESCRIPTOR_TYPE_SINT64:\n case UPB_DESCRIPTOR_TYPE_SFIXED64:\n return UPB_TYPE_INT64;\n case UPB_DESCRIPTOR_TYPE_INT32:\n case UPB_DESCRIPTOR_TYPE_SFIXED32:\n case UPB_DESCRIPTOR_TYPE_SINT32:\n return UPB_TYPE_INT32;\n case UPB_DESCRIPTOR_TYPE_UINT64:\n case UPB_DESCRIPTOR_TYPE_FIXED64:\n return UPB_TYPE_UINT64;\n case UPB_DESCRIPTOR_TYPE_UINT32:\n case UPB_DESCRIPTOR_TYPE_FIXED32:\n return UPB_TYPE_UINT32;\n case UPB_DESCRIPTOR_TYPE_ENUM:\n return UPB_TYPE_ENUM;\n case UPB_DESCRIPTOR_TYPE_BOOL:\n return UPB_TYPE_BOOL;\n case UPB_DESCRIPTOR_TYPE_STRING:\n return UPB_TYPE_STRING;\n case UPB_DESCRIPTOR_TYPE_BYTES:\n return UPB_TYPE_BYTES;\n case UPB_DESCRIPTOR_TYPE_GROUP:\n case UPB_DESCRIPTOR_TYPE_MESSAGE:\n return UPB_TYPE_MESSAGE;\n }\n UPB_UNREACHABLE();\n}\n\nupb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f) {\n return f->type_;\n}\n\nuint32_t upb_fielddef_index(const upb_fielddef *f) {\n return f->index_;\n}\n\nupb_label_t upb_fielddef_label(const upb_fielddef *f) {\n return f->label_;\n}\n\nuint32_t upb_fielddef_number(const upb_fielddef *f) {\n return f->number_;\n}\n\nbool upb_fielddef_isextension(const upb_fielddef *f) {\n return f->is_extension_;\n}\n\nbool upb_fielddef_lazy(const upb_fielddef *f) {\n return f->lazy_;\n}\n\nbool upb_fielddef_packed(const upb_fielddef *f) {\n return f->packed_;\n}\n\nconst char *upb_fielddef_name(const upb_fielddef *f) {\n return shortdefname(f->full_name);\n}\n\nconst char *upb_fielddef_jsonname(const upb_fielddef *f) {\n return f->json_name;\n}\n\nuint32_t upb_fielddef_selectorbase(const upb_fielddef *f) {\n return f->selector_base;\n}\n\nconst upb_filedef *upb_fielddef_file(const upb_fielddef *f) {\n return f->file;\n}\n\nconst upb_msgdef *upb_fielddef_containingtype(const upb_fielddef *f) {\n return f->msgdef;\n}\n\nconst upb_oneofdef *upb_fielddef_containingoneof(const upb_fielddef *f) {\n return f->oneof;\n}\n\nconst upb_oneofdef *upb_fielddef_realcontainingoneof(const upb_fielddef *f) {\n if (!f->oneof || upb_oneofdef_issynthetic(f->oneof)) return NULL;\n return f->oneof;\n}\n\nstatic void chkdefaulttype(const upb_fielddef *f, int ctype) {\n UPB_UNUSED(f);\n UPB_UNUSED(ctype);\n}\n\nint64_t upb_fielddef_defaultint64(const upb_fielddef *f) {\n chkdefaulttype(f, UPB_TYPE_INT64);\n return f->defaultval.sint;\n}\n\nint32_t upb_fielddef_defaultint32(const upb_fielddef *f) {\n chkdefaulttype(f, UPB_TYPE_INT32);\n return (int32_t)f->defaultval.sint;\n}\n\nuint64_t upb_fielddef_defaultuint64(const upb_fielddef *f) {\n chkdefaulttype(f, UPB_TYPE_UINT64);\n return f->defaultval.uint;\n}\n\nuint32_t upb_fielddef_defaultuint32(const upb_fielddef *f) {\n chkdefaulttype(f, UPB_TYPE_UINT32);\n return (uint32_t)f->defaultval.uint;\n}\n\nbool upb_fielddef_defaultbool(const upb_fielddef *f) {\n chkdefaulttype(f, UPB_TYPE_BOOL);\n return f->defaultval.boolean;\n}\n\nfloat upb_fielddef_defaultfloat(const upb_fielddef *f) {\n chkdefaulttype(f, UPB_TYPE_FLOAT);\n return f->defaultval.flt;\n}\n\ndouble upb_fielddef_defaultdouble(const upb_fielddef *f) {\n chkdefaulttype(f, UPB_TYPE_DOUBLE);\n return f->defaultval.dbl;\n}\n\nconst char *upb_fielddef_defaultstr(const upb_fielddef *f, size_t *len) {\n str_t *str = f->defaultval.str;\n UPB_ASSERT(upb_fielddef_type(f) == UPB_TYPE_STRING ||\n upb_fielddef_type(f) == UPB_TYPE_BYTES ||\n upb_fielddef_type(f) == UPB_TYPE_ENUM);\n if (str) {\n if (len) *len = str->len;\n return str->str;\n } else {\n if (len) *len = 0;\n return NULL;\n }\n}\n\nconst upb_msgdef *upb_fielddef_msgsubdef(const upb_fielddef *f) {\n return upb_fielddef_type(f) == UPB_TYPE_MESSAGE ? f->sub.msgdef : NULL;\n}\n\nconst upb_enumdef *upb_fielddef_enumsubdef(const upb_fielddef *f) {\n return upb_fielddef_type(f) == UPB_TYPE_ENUM ? f->sub.enumdef : NULL;\n}\n\nconst upb_msglayout_field *upb_fielddef_layout(const upb_fielddef *f) {\n return &f->msgdef->layout->fields[f->layout_index];\n}\n\nbool upb_fielddef_issubmsg(const upb_fielddef *f) {\n return upb_fielddef_type(f) == UPB_TYPE_MESSAGE;\n}\n\nbool upb_fielddef_isstring(const upb_fielddef *f) {\n return upb_fielddef_type(f) == UPB_TYPE_STRING ||\n upb_fielddef_type(f) == UPB_TYPE_BYTES;\n}\n\nbool upb_fielddef_isseq(const upb_fielddef *f) {\n return upb_fielddef_label(f) == UPB_LABEL_REPEATED;\n}\n\nbool upb_fielddef_isprimitive(const upb_fielddef *f) {\n return !upb_fielddef_isstring(f) && !upb_fielddef_issubmsg(f);\n}\n\nbool upb_fielddef_ismap(const upb_fielddef *f) {\n return upb_fielddef_isseq(f) && upb_fielddef_issubmsg(f) &&\n upb_msgdef_mapentry(upb_fielddef_msgsubdef(f));\n}\n\nbool upb_fielddef_hassubdef(const upb_fielddef *f) {\n return upb_fielddef_issubmsg(f) || upb_fielddef_type(f) == UPB_TYPE_ENUM;\n}\n\nbool upb_fielddef_haspresence(const upb_fielddef *f) {\n if (upb_fielddef_isseq(f)) return false;\n return upb_fielddef_issubmsg(f) || upb_fielddef_containingoneof(f) ||\n f->file->syntax == UPB_SYNTAX_PROTO2;\n}\n\nstatic bool between(int32_t x, int32_t low, int32_t high) {\n return x >= low && x <= high;\n}\n\nbool upb_fielddef_checklabel(int32_t label) { return between(label, 1, 3); }\nbool upb_fielddef_checktype(int32_t type) { return between(type, 1, 11); }\nbool upb_fielddef_checkintfmt(int32_t fmt) { return between(fmt, 1, 3); }\n\nbool upb_fielddef_checkdescriptortype(int32_t type) {\n return between(type, 1, 18);\n}\n\n\/* upb_msgdef *****************************************************************\/\n\nconst char *upb_msgdef_fullname(const upb_msgdef *m) {\n return m->full_name;\n}\n\nconst upb_filedef *upb_msgdef_file(const upb_msgdef *m) {\n return m->file;\n}\n\nconst char *upb_msgdef_name(const upb_msgdef *m) {\n return shortdefname(m->full_name);\n}\n\nupb_syntax_t upb_msgdef_syntax(const upb_msgdef *m) {\n return m->file->syntax;\n}\n\nsize_t upb_msgdef_selectorcount(const upb_msgdef *m) {\n return m->selector_count;\n}\n\nuint32_t upb_msgdef_submsgfieldcount(const upb_msgdef *m) {\n return m->submsg_field_count;\n}\n\nconst upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i) {\n upb_value val;\n return upb_inttable_lookup32(&m->itof, i, &val) ?\n upb_value_getconstptr(val) : NULL;\n}\n\nconst upb_fielddef *upb_msgdef_ntof(const upb_msgdef *m, const char *name,\n size_t len) {\n upb_value val;\n\n if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) {\n return NULL;\n }\n\n return unpack_def(val, UPB_DEFTYPE_FIELD);\n}\n\nconst upb_oneofdef *upb_msgdef_ntoo(const upb_msgdef *m, const char *name,\n size_t len) {\n upb_value val;\n\n if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) {\n return NULL;\n }\n\n return unpack_def(val, UPB_DEFTYPE_ONEOF);\n}\n\nbool upb_msgdef_lookupname(const upb_msgdef *m, const char *name, size_t len,\n const upb_fielddef **f, const upb_oneofdef **o) {\n upb_value val;\n\n if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) {\n return false;\n }\n\n *o = unpack_def(val, UPB_DEFTYPE_ONEOF);\n *f = unpack_def(val, UPB_DEFTYPE_FIELD);\n return *o || *f; \/* False if this was a JSON name. *\/\n}\n\nconst upb_fielddef *upb_msgdef_lookupjsonname(const upb_msgdef *m,\n const char *name, size_t len) {\n upb_value val;\n const upb_fielddef* f;\n\n if (!upb_strtable_lookup2(&m->ntof, name, len, &val)) {\n return NULL;\n }\n\n f = unpack_def(val, UPB_DEFTYPE_FIELD);\n if (!f) f = unpack_def(val, UPB_DEFTYPE_FIELD_JSONNAME);\n\n return f;\n}\n\nint upb_msgdef_numfields(const upb_msgdef *m) {\n return m->field_count;\n}\n\nint upb_msgdef_numoneofs(const upb_msgdef *m) {\n return m->oneof_count;\n}\n\nint upb_msgdef_numrealoneofs(const upb_msgdef *m) {\n return m->real_oneof_count;\n}\n\nint upb_msgdef_fieldcount(const upb_msgdef *m) {\n return m->field_count;\n}\n\nint upb_msgdef_oneofcount(const upb_msgdef *m) {\n return m->oneof_count;\n}\n\nint upb_msgdef_realoneofcount(const upb_msgdef *m) {\n return m->real_oneof_count;\n}\n\nconst upb_msglayout *upb_msgdef_layout(const upb_msgdef *m) {\n return m->layout;\n}\n\nconst upb_fielddef *upb_msgdef_field(const upb_msgdef *m, int i) {\n UPB_ASSERT(i >= 0 && i < m->field_count);\n return &m->fields[i];\n}\n\nconst upb_oneofdef *upb_msgdef_oneof(const upb_msgdef *m, int i) {\n UPB_ASSERT(i >= 0 && i < m->oneof_count);\n return &m->oneofs[i];\n}\n\nbool upb_msgdef_mapentry(const upb_msgdef *m) {\n return m->map_entry;\n}\n\nupb_wellknowntype_t upb_msgdef_wellknowntype(const upb_msgdef *m) {\n return m->well_known_type;\n}\n\nbool upb_msgdef_isnumberwrapper(const upb_msgdef *m) {\n upb_wellknowntype_t type = upb_msgdef_wellknowntype(m);\n return type >= UPB_WELLKNOWN_DOUBLEVALUE &&\n type <= UPB_WELLKNOWN_UINT32VALUE;\n}\n\nbool upb_msgdef_iswrapper(const upb_msgdef *m) {\n upb_wellknowntype_t type = upb_msgdef_wellknowntype(m);\n return type >= UPB_WELLKNOWN_DOUBLEVALUE &&\n type <= UPB_WELLKNOWN_BOOLVALUE;\n}\n\nvoid upb_msg_field_begin(upb_msg_field_iter *iter, const upb_msgdef *m) {\n upb_inttable_begin(iter, &m->itof);\n}\n\nvoid upb_msg_field_next(upb_msg_field_iter *iter) { upb_inttable_next(iter); }\n\nbool upb_msg_field_done(const upb_msg_field_iter *iter) {\n return upb_inttable_done(iter);\n}\n\nupb_fielddef *upb_msg_iter_field(const upb_msg_field_iter *iter) {\n return (upb_fielddef *)upb_value_getconstptr(upb_inttable_iter_value(iter));\n}\n\nvoid upb_msg_field_iter_setdone(upb_msg_field_iter *iter) {\n upb_inttable_iter_setdone(iter);\n}\n\nbool upb_msg_field_iter_isequal(const upb_msg_field_iter * iter1,\n const upb_msg_field_iter * iter2) {\n return upb_inttable_iter_isequal(iter1, iter2);\n}\n\nvoid upb_msg_oneof_begin(upb_msg_oneof_iter *iter, const upb_msgdef *m) {\n upb_strtable_begin(iter, &m->ntof);\n \/* We need to skip past any initial fields. *\/\n while (!upb_strtable_done(iter) &&\n !unpack_def(upb_strtable_iter_value(iter), UPB_DEFTYPE_ONEOF)) {\n upb_strtable_next(iter);\n }\n}\n\nvoid upb_msg_oneof_next(upb_msg_oneof_iter *iter) {\n \/* We need to skip past fields to return only oneofs. *\/\n do {\n upb_strtable_next(iter);\n } while (!upb_strtable_done(iter) &&\n !unpack_def(upb_strtable_iter_value(iter), UPB_DEFTYPE_ONEOF));\n}\n\nbool upb_msg_oneof_done(const upb_msg_oneof_iter *iter) {\n return upb_strtable_done(iter);\n}\n\nconst upb_oneofdef *upb_msg_iter_oneof(const upb_msg_oneof_iter *iter) {\n return unpack_def(upb_strtable_iter_value(iter), UPB_DEFTYPE_ONEOF);\n}\n\nvoid upb_msg_oneof_iter_setdone(upb_msg_oneof_iter *iter) {\n upb_strtable_iter_setdone(iter);\n}\n\nbool upb_msg_oneof_iter_isequal(const upb_msg_oneof_iter *iter1,\n const upb_msg_oneof_iter *iter2) {\n return upb_strtable_iter_isequal(iter1, iter2);\n}\n\n\/* upb_oneofdef ***************************************************************\/\n\nconst char *upb_oneofdef_name(const upb_oneofdef *o) {\n return shortdefname(o->full_name);\n}\n\nconst upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o) {\n return o->parent;\n}\n\nint upb_oneofdef_fieldcount(const upb_oneofdef *o) {\n return o->field_count;\n}\n\nconst upb_fielddef *upb_oneofdef_field(const upb_oneofdef *o, int i) {\n UPB_ASSERT(i < o->field_count);\n return o->fields[i];\n}\n\nint upb_oneofdef_numfields(const upb_oneofdef *o) {\n return o->field_count;\n}\n\nuint32_t upb_oneofdef_index(const upb_oneofdef *o) {\n return o - o->parent->oneofs;\n}\n\nbool upb_oneofdef_issynthetic(const upb_oneofdef *o) {\n return o->synthetic;\n}\n\nconst upb_fielddef *upb_oneofdef_ntof(const upb_oneofdef *o,\n const char *name, size_t length) {\n upb_value val;\n return upb_strtable_lookup2(&o->ntof, name, length, &val) ?\n upb_value_getptr(val) : NULL;\n}\n\nconst upb_fielddef *upb_oneofdef_itof(const upb_oneofdef *o, uint32_t num) {\n upb_value val;\n return upb_inttable_lookup32(&o->itof, num, &val) ?\n upb_value_getptr(val) : NULL;\n}\n\nvoid upb_oneof_begin(upb_oneof_iter *iter, const upb_oneofdef *o) {\n upb_inttable_begin(iter, &o->itof);\n}\n\nvoid upb_oneof_next(upb_oneof_iter *iter) {\n upb_inttable_next(iter);\n}\n\nbool upb_oneof_done(upb_oneof_iter *iter) {\n return upb_inttable_done(iter);\n}\n\nupb_fielddef *upb_oneof_iter_field(const upb_oneof_iter *iter) {\n return (upb_fielddef *)upb_value_getconstptr(upb_inttable_iter_value(iter));\n}\n\nvoid upb_oneof_iter_setdone(upb_oneof_iter *iter) {\n upb_inttable_iter_setdone(iter);\n}\n\n\/* upb_filedef ****************************************************************\/\n\nconst char *upb_filedef_name(const upb_filedef *f) {\n return f->name;\n}\n\nconst char *upb_filedef_package(const upb_filedef *f) {\n return f->package;\n}\n\nconst char *upb_filedef_phpprefix(const upb_filedef *f) {\n return f->phpprefix;\n}\n\nconst char *upb_filedef_phpnamespace(const upb_filedef *f) {\n return f->phpnamespace;\n}\n\nupb_syntax_t upb_filedef_syntax(const upb_filedef *f) {\n return f->syntax;\n}\n\nint upb_filedef_msgcount(const upb_filedef *f) {\n return f->msg_count;\n}\n\nint upb_filedef_depcount(const upb_filedef *f) {\n return f->dep_count;\n}\n\nint upb_filedef_enumcount(const upb_filedef *f) {\n return f->enum_count;\n}\n\nconst upb_filedef *upb_filedef_dep(const upb_filedef *f, int i) {\n return i < 0 || i >= f->dep_count ? NULL : f->deps[i];\n}\n\nconst upb_msgdef *upb_filedef_msg(const upb_filedef *f, int i) {\n return i < 0 || i >= f->msg_count ? NULL : &f->msgs[i];\n}\n\nconst upb_enumdef *upb_filedef_enum(const upb_filedef *f, int i) {\n return i < 0 || i >= f->enum_count ? NULL : &f->enums[i];\n}\n\nvoid upb_symtab_free(upb_symtab *s) {\n upb_arena_free(s->arena);\n upb_gfree(s);\n}\n\nupb_symtab *upb_symtab_new(void) {\n upb_symtab *s = upb_gmalloc(sizeof(*s));\n upb_alloc *alloc;\n\n if (!s) {\n return NULL;\n }\n\n s->arena = upb_arena_new();\n s->bytes_loaded = 0;\n alloc = upb_arena_alloc(s->arena);\n\n if (!upb_strtable_init2(&s->syms, UPB_CTYPE_CONSTPTR, 32, alloc) ||\n !upb_strtable_init2(&s->files, UPB_CTYPE_CONSTPTR, 4, alloc)) {\n upb_arena_free(s->arena);\n upb_gfree(s);\n s = NULL;\n }\n return s;\n}\n\nconst upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym) {\n upb_value v;\n return upb_strtable_lookup(&s->syms, sym, &v) ?\n unpack_def(v, UPB_DEFTYPE_MSG) : NULL;\n}\n\nconst upb_msgdef *upb_symtab_lookupmsg2(const upb_symtab *s, const char *sym,\n size_t len) {\n upb_value v;\n return upb_strtable_lookup2(&s->syms, sym, len, &v) ?\n unpack_def(v, UPB_DEFTYPE_MSG) : NULL;\n}\n\nconst upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym) {\n upb_value v;\n return upb_strtable_lookup(&s->syms, sym, &v) ?\n unpack_def(v, UPB_DEFTYPE_ENUM) : NULL;\n}\n\nconst upb_filedef *upb_symtab_lookupfile(const upb_symtab *s, const char *name) {\n upb_value v;\n return upb_strtable_lookup(&s->files, name, &v) ? upb_value_getconstptr(v)\n : NULL;\n}\n\nconst upb_filedef *upb_symtab_lookupfile2(\n const upb_symtab *s, const char *name, size_t len) {\n upb_value v;\n return upb_strtable_lookup2(&s->files, name, len, &v) ?\n upb_value_getconstptr(v) : NULL;\n}\n\nint upb_symtab_filecount(const upb_symtab *s) {\n return (int)upb_strtable_count(&s->files);\n}\n\n\/* Code to build defs from descriptor protos. *********************************\/\n\n\/* There is a question of how much validation to do here. It will be difficult\n * to perfectly match the amount of validation performed by proto2. But since\n * this code is used to directly build defs from Ruby (for example) we do need\n * to validate important constraints like uniqueness of names and numbers. *\/\n\n#define CHK_OOM(x) if (!(x)) { symtab_oomerr(ctx); }\n\ntypedef struct {\n upb_symtab *symtab;\n upb_filedef *file; \/* File we are building. *\/\n upb_arena *file_arena; \/* Allocate defs here. *\/\n upb_alloc *alloc; \/* Alloc of file_arena, for tables. *\/\n const upb_msglayout **layouts; \/* NULL if we should build layouts. *\/\n upb_status *status; \/* Record errors here. *\/\n jmp_buf err; \/* longjmp() on error. *\/\n} symtab_addctx;\n\nUPB_NORETURN UPB_NOINLINE\nstatic void symtab_errf(symtab_addctx *ctx, const char *fmt, ...) {\n va_list argp;\n va_start(argp, fmt);\n upb_status_vseterrf(ctx->status, fmt, argp);\n va_end(argp);\n UPB_LONGJMP(ctx->err, 1);\n}\n\nUPB_NORETURN UPB_NOINLINE\nstatic void symtab_oomerr(symtab_addctx *ctx) {\n upb_status_setoom(ctx->status);\n UPB_LONGJMP(ctx->err, 1);\n}\n\nvoid *symtab_alloc(symtab_addctx *ctx, size_t bytes) {\n void *ret = upb_arena_malloc(ctx->file_arena, bytes);\n if (!ret) symtab_oomerr(ctx);\n return ret;\n}\n\nstatic void check_ident(symtab_addctx *ctx, upb_strview name, bool full) {\n const char *str = name.data;\n size_t len = name.size;\n bool start = true;\n size_t i;\n for (i = 0; i < len; i++) {\n char c = str[i];\n if (c == '.') {\n if (start || !full) {\n symtab_errf(ctx, \"invalid name: unexpected '.' (%.*s)\", (int)len, str);\n }\n start = true;\n } else if (start) {\n if (!upb_isletter(c)) {\n symtab_errf(\n ctx,\n \"invalid name: path components must start with a letter (%.*s)\",\n (int)len, str);\n }\n start = false;\n } else {\n if (!upb_isalphanum(c)) {\n symtab_errf(ctx, \"invalid name: non-alphanumeric character (%.*s)\",\n (int)len, str);\n }\n }\n }\n if (start) {\n symtab_errf(ctx, \"invalid name: empty part (%.*s)\", (int)len, str);\n }\n}\n\nstatic size_t div_round_up(size_t n, size_t d) {\n return (n + d - 1) \/ d;\n}\n\nstatic size_t upb_msgval_sizeof(upb_fieldtype_t type) {\n switch (type) {\n case UPB_TYPE_DOUBLE:\n case UPB_TYPE_INT64:\n case UPB_TYPE_UINT64:\n return 8;\n case UPB_TYPE_ENUM:\n case UPB_TYPE_INT32:\n case UPB_TYPE_UINT32:\n case UPB_TYPE_FLOAT:\n return 4;\n case UPB_TYPE_BOOL:\n return 1;\n case UPB_TYPE_MESSAGE:\n return sizeof(void*);\n case UPB_TYPE_BYTES:\n case UPB_TYPE_STRING:\n return sizeof(upb_strview);\n }\n UPB_UNREACHABLE();\n}\n\nstatic uint8_t upb_msg_fielddefsize(const upb_fielddef *f) {\n if (upb_msgdef_mapentry(upb_fielddef_containingtype(f))) {\n upb_map_entry ent;\n UPB_ASSERT(sizeof(ent.k) == sizeof(ent.v));\n return sizeof(ent.k);\n } else if (upb_fielddef_isseq(f)) {\n return sizeof(void*);\n } else {\n return upb_msgval_sizeof(upb_fielddef_type(f));\n }\n}\n\nstatic uint32_t upb_msglayout_place(upb_msglayout *l, size_t size) {\n uint32_t ret;\n\n l->size = UPB_ALIGN_UP(l->size, size);\n ret = l->size;\n l->size += size;\n return ret;\n}\n\nstatic int field_number_cmp(const void *p1, const void *p2) {\n const upb_msglayout_field *f1 = p1;\n const upb_msglayout_field *f2 = p2;\n return f1->number - f2->number;\n}\n\nstatic void assign_layout_indices(const upb_msgdef *m, upb_msglayout_field *fields) {\n int i;\n int n = upb_msgdef_numfields(m);\n for (i = 0; i < n; i++) {\n upb_fielddef *f = (upb_fielddef*)upb_msgdef_itof(m, fields[i].number);\n UPB_ASSERT(f);\n f->layout_index = i;\n }\n}\n\n\/* This function is the dynamic equivalent of message_layout.{cc,h} in upbc.\n * It computes a dynamic layout for all of the fields in |m|. *\/\nstatic void make_layout(symtab_addctx *ctx, const upb_msgdef *m) {\n upb_msglayout *l = (upb_msglayout*)m->layout;\n upb_msg_field_iter it;\n upb_msg_oneof_iter oit;\n size_t hasbit;\n size_t submsg_count = m->submsg_field_count;\n const upb_msglayout **submsgs;\n upb_msglayout_field *fields;\n\n memset(l, 0, sizeof(*l) + sizeof(_upb_fasttable_entry));\n\n fields = symtab_alloc(ctx, upb_msgdef_numfields(m) * sizeof(*fields));\n submsgs = symtab_alloc(ctx, submsg_count * sizeof(*submsgs));\n\n l->field_count = upb_msgdef_numfields(m);\n l->fields = fields;\n l->submsgs = submsgs;\n l->table_mask = 0;\n\n \/* TODO(haberman): initialize fast tables so that reflection-based parsing\n * can get the same speeds as linked-in types. *\/\n l->fasttable[0].field_parser = &fastdecode_generic;\n l->fasttable[0].field_data = 0;\n\n if (upb_msgdef_mapentry(m)) {\n \/* TODO(haberman): refactor this method so this special case is more\n * elegant. *\/\n const upb_fielddef *key = upb_msgdef_itof(m, 1);\n const upb_fielddef *val = upb_msgdef_itof(m, 2);\n fields[0].number = 1;\n fields[1].number = 2;\n fields[0].label = UPB_LABEL_OPTIONAL;\n fields[1].label = UPB_LABEL_OPTIONAL;\n fields[0].presence = 0;\n fields[1].presence = 0;\n fields[0].descriptortype = upb_fielddef_descriptortype(key);\n fields[1].descriptortype = upb_fielddef_descriptortype(val);\n fields[0].offset = 0;\n fields[1].offset = sizeof(upb_strview);\n fields[1].submsg_index = 0;\n\n if (upb_fielddef_type(val) == UPB_TYPE_MESSAGE) {\n submsgs[0] = upb_fielddef_msgsubdef(val)->layout;\n }\n\n l->field_count = 2;\n l->size = 2 * sizeof(upb_strview);\n l->size = UPB_ALIGN_UP(l->size, 8);\n return;\n }\n\n \/* Allocate data offsets in three stages:\n *\n * 1. hasbits.\n * 2. regular fields.\n * 3. oneof fields.\n *\n * OPT: There is a lot of room for optimization here to minimize the size.\n *\/\n\n \/* Allocate hasbits and set basic field attributes. *\/\n submsg_count = 0;\n for (upb_msg_field_begin(&it, m), hasbit = 0;\n !upb_msg_field_done(&it);\n upb_msg_field_next(&it)) {\n upb_fielddef* f = upb_msg_iter_field(&it);\n upb_msglayout_field *field = &fields[upb_fielddef_index(f)];\n\n field->number = upb_fielddef_number(f);\n field->descriptortype = upb_fielddef_descriptortype(f);\n field->label = upb_fielddef_label(f);\n\n if (field->descriptortype == UPB_DTYPE_STRING &&\n f->file->syntax == UPB_SYNTAX_PROTO2) {\n \/* See TableDescriptorType() in upbc\/generator.cc for details and\n * rationale. *\/\n field->descriptortype = UPB_DTYPE_BYTES;\n }\n\n if (upb_fielddef_ismap(f)) {\n field->label = _UPB_LABEL_MAP;\n } else if (upb_fielddef_packed(f)) {\n field->label = _UPB_LABEL_PACKED;\n }\n\n if (upb_fielddef_issubmsg(f)) {\n const upb_msgdef *subm = upb_fielddef_msgsubdef(f);\n field->submsg_index = submsg_count++;\n submsgs[field->submsg_index] = subm->layout;\n }\n\n if (upb_fielddef_haspresence(f) && !upb_fielddef_realcontainingoneof(f)) {\n \/* We don't use hasbit 0, so that 0 can indicate \"no presence\" in the\n * table. This wastes one hasbit, but we don't worry about it for now. *\/\n field->presence = ++hasbit;\n } else {\n field->presence = 0;\n }\n }\n\n \/* Account for space used by hasbits. *\/\n l->size = div_round_up(hasbit, 8);\n\n \/* Allocate non-oneof fields. *\/\n for (upb_msg_field_begin(&it, m); !upb_msg_field_done(&it);\n upb_msg_field_next(&it)) {\n const upb_fielddef* f = upb_msg_iter_field(&it);\n size_t field_size = upb_msg_fielddefsize(f);\n size_t index = upb_fielddef_index(f);\n\n if (upb_fielddef_realcontainingoneof(f)) {\n \/* Oneofs are handled separately below. *\/\n continue;\n }\n\n fields[index].offset = upb_msglayout_place(l, field_size);\n }\n\n \/* Allocate oneof fields. Each oneof field consists of a uint32 for the case\n * and space for the actual data. *\/\n for (upb_msg_oneof_begin(&oit, m); !upb_msg_oneof_done(&oit);\n upb_msg_oneof_next(&oit)) {\n const upb_oneofdef* o = upb_msg_iter_oneof(&oit);\n upb_oneof_iter fit;\n\n size_t case_size = sizeof(uint32_t); \/* Could potentially optimize this. *\/\n size_t field_size = 0;\n uint32_t case_offset;\n uint32_t data_offset;\n\n if (upb_oneofdef_issynthetic(o)) continue;\n\n \/* Calculate field size: the max of all field sizes. *\/\n for (upb_oneof_begin(&fit, o);\n !upb_oneof_done(&fit);\n upb_oneof_next(&fit)) {\n const upb_fielddef* f = upb_oneof_iter_field(&fit);\n field_size = UPB_MAX(field_size, upb_msg_fielddefsize(f));\n }\n\n \/* Align and allocate case offset. *\/\n case_offset = upb_msglayout_place(l, case_size);\n data_offset = upb_msglayout_place(l, field_size);\n\n for (upb_oneof_begin(&fit, o);\n !upb_oneof_done(&fit);\n upb_oneof_next(&fit)) {\n const upb_fielddef* f = upb_oneof_iter_field(&fit);\n fields[upb_fielddef_index(f)].offset = data_offset;\n fields[upb_fielddef_index(f)].presence = ~case_offset;\n }\n }\n\n \/* Size of the entire structure should be a multiple of its greatest\n * alignment. TODO: track overall alignment for real? *\/\n l->size = UPB_ALIGN_UP(l->size, 8);\n\n \/* Sort fields by number. *\/\n qsort(fields, upb_msgdef_numfields(m), sizeof(*fields), field_number_cmp);\n assign_layout_indices(m, fields);\n}\n\nstatic void assign_msg_indices(symtab_addctx *ctx, upb_msgdef *m) {\n \/* Sort fields. upb internally relies on UPB_TYPE_MESSAGE fields having the\n * lowest indexes, but we do not publicly guarantee this. *\/\n upb_msg_field_iter j;\n int i;\n uint32_t selector;\n int n = upb_msgdef_numfields(m);\n upb_fielddef **fields;\n\n if (n == 0) {\n m->selector_count = UPB_STATIC_SELECTOR_COUNT;\n m->submsg_field_count = 0;\n return;\n }\n\n fields = upb_gmalloc(n * sizeof(*fields));\n\n m->submsg_field_count = 0;\n for(i = 0, upb_msg_field_begin(&j, m);\n !upb_msg_field_done(&j);\n upb_msg_field_next(&j), i++) {\n upb_fielddef *f = upb_msg_iter_field(&j);\n UPB_ASSERT(f->msgdef == m);\n if (upb_fielddef_issubmsg(f)) {\n m->submsg_field_count++;\n }\n fields[i] = f;\n }\n\n qsort(fields, n, sizeof(*fields), cmp_fields);\n\n selector = UPB_STATIC_SELECTOR_COUNT + m->submsg_field_count;\n for (i = 0; i < n; i++) {\n upb_fielddef *f = fields[i];\n f->index_ = i;\n f->selector_base = selector + upb_handlers_selectorbaseoffset(f);\n selector += upb_handlers_selectorcount(f);\n }\n m->selector_count = selector;\n\n upb_gfree(fields);\n}\n\nstatic char *strviewdup(symtab_addctx *ctx, upb_strview view) {\n return upb_strdup2(view.data, view.size, ctx->alloc);\n}\n\nstatic bool streql2(const char *a, size_t n, const char *b) {\n return n == strlen(b) && memcmp(a, b, n) == 0;\n}\n\nstatic bool streql_view(upb_strview view, const char *b) {\n return streql2(view.data, view.size, b);\n}\n\nstatic const char *makefullname(symtab_addctx *ctx, const char *prefix,\n upb_strview name) {\n if (prefix) {\n \/* ret = prefix + '.' + name; *\/\n size_t n = strlen(prefix);\n char *ret = symtab_alloc(ctx, n + name.size + 2);\n strcpy(ret, prefix);\n ret[n] = '.';\n memcpy(&ret[n + 1], name.data, name.size);\n ret[n + 1 + name.size] = '\\0';\n return ret;\n } else {\n return strviewdup(ctx, name);\n }\n}\n\nstatic void finalize_oneofs(symtab_addctx *ctx, upb_msgdef *m) {\n int i;\n int synthetic_count = 0;\n upb_oneofdef *mutable_oneofs = (upb_oneofdef*)m->oneofs;\n\n for (i = 0; i < m->oneof_count; i++) {\n upb_oneofdef *o = &mutable_oneofs[i];\n\n if (o->synthetic && o->field_count != 1) {\n symtab_errf(ctx, \"Synthetic oneofs must have one field, not %d: %s\",\n o->field_count, upb_oneofdef_name(o));\n }\n\n if (o->synthetic) {\n synthetic_count++;\n } else if (synthetic_count != 0) {\n symtab_errf(ctx, \"Synthetic oneofs must be after all other oneofs: %s\",\n upb_oneofdef_name(o));\n }\n\n o->fields = symtab_alloc(ctx, sizeof(upb_fielddef *) * o->field_count);\n o->field_count = 0;\n }\n\n for (i = 0; i < m->field_count; i++) {\n const upb_fielddef *f = &m->fields[i];\n upb_oneofdef *o = (upb_oneofdef*)f->oneof;\n if (o) {\n o->fields[o->field_count++] = f;\n }\n }\n\n m->real_oneof_count = m->oneof_count - synthetic_count;\n}\n\nsize_t getjsonname(const char *name, char *buf, size_t len) {\n size_t src, dst = 0;\n bool ucase_next = false;\n\n#define WRITE(byte) \\\n ++dst; \\\n if (dst < len) buf[dst - 1] = byte; \\\n else if (dst == len) buf[dst - 1] = '\\0'\n\n if (!name) {\n WRITE('\\0');\n return 0;\n }\n\n \/* Implement the transformation as described in the spec:\n * 1. upper case all letters after an underscore.\n * 2. remove all underscores.\n *\/\n for (src = 0; name[src]; src++) {\n if (name[src] == '_') {\n ucase_next = true;\n continue;\n }\n\n if (ucase_next) {\n WRITE(toupper(name[src]));\n ucase_next = false;\n } else {\n WRITE(name[src]);\n }\n }\n\n WRITE('\\0');\n return dst;\n\n#undef WRITE\n}\n\nstatic char* makejsonname(symtab_addctx *ctx, const char* name) {\n size_t size = getjsonname(name, NULL, 0);\n char* json_name = symtab_alloc(ctx, size);\n getjsonname(name, json_name, size);\n return json_name;\n}\n\nstatic void symtab_add(symtab_addctx *ctx, const char *name, upb_value v) {\n if (upb_strtable_lookup(&ctx->symtab->syms, name, NULL)) {\n symtab_errf(ctx, \"duplicate symbol '%s'\", name);\n }\n upb_alloc *alloc = upb_arena_alloc(ctx->symtab->arena);\n size_t len = strlen(name);\n CHK_OOM(upb_strtable_insert3(&ctx->symtab->syms, name, len, v, alloc));\n}\n\n\/* Given a symbol and the base symbol inside which it is defined, find the\n * symbol's definition in t. *\/\nstatic const void *symtab_resolve(symtab_addctx *ctx, const upb_fielddef *f,\n const char *base, upb_strview sym,\n upb_deftype_t type) {\n const upb_strtable *t = &ctx->symtab->syms;\n if(sym.size == 0) goto notfound;\n if(sym.data[0] == '.') {\n \/* Symbols starting with '.' are absolute, so we do a single lookup.\n * Slice to omit the leading '.' *\/\n upb_value v;\n if (!upb_strtable_lookup2(t, sym.data + 1, sym.size - 1, &v)) {\n goto notfound;\n }\n\n const void *ret = unpack_def(v, type);\n if (!ret) {\n symtab_errf(ctx, \"type mismatch when resolving field %s, name %s\",\n f->full_name, sym.data);\n }\n return ret;\n } else {\n \/* Remove components from base until we find an entry or run out.\n * TODO: This branch is totally broken, but currently not used. *\/\n (void)base;\n UPB_ASSERT(false);\n goto notfound;\n }\n\nnotfound:\n symtab_errf(ctx, \"couldn't resolve name '%s'\", sym.data);\n}\n\nstatic void create_oneofdef(\n symtab_addctx *ctx, upb_msgdef *m,\n const google_protobuf_OneofDescriptorProto *oneof_proto) {\n upb_oneofdef *o;\n upb_strview name = google_protobuf_OneofDescriptorProto_name(oneof_proto);\n upb_value v;\n\n o = (upb_oneofdef*)&m->oneofs[m->oneof_count++];\n o->parent = m;\n o->full_name = makefullname(ctx, m->full_name, name);\n o->field_count = 0;\n o->synthetic = false;\n\n v = pack_def(o, UPB_DEFTYPE_ONEOF);\n symtab_add(ctx, o->full_name, v);\n CHK_OOM(upb_strtable_insert3(&m->ntof, name.data, name.size, v, ctx->alloc));\n\n CHK_OOM(upb_inttable_init2(&o->itof, UPB_CTYPE_CONSTPTR, ctx->alloc));\n CHK_OOM(upb_strtable_init2(&o->ntof, UPB_CTYPE_CONSTPTR, 4, ctx->alloc));\n}\n\nstatic str_t *newstr(symtab_addctx *ctx, const char *data, size_t len) {\n str_t *ret = symtab_alloc(ctx, sizeof(*ret) + len);\n if (!ret) return NULL;\n ret->len = len;\n if (len) memcpy(ret->str, data, len);\n ret->str[len] = '\\0';\n return ret;\n}\n\nstatic void parse_default(symtab_addctx *ctx, const char *str, size_t len,\n upb_fielddef *f) {\n char *end;\n char nullz[64];\n errno = 0;\n\n switch (upb_fielddef_type(f)) {\n case UPB_TYPE_INT32:\n case UPB_TYPE_INT64:\n case UPB_TYPE_UINT32:\n case UPB_TYPE_UINT64:\n case UPB_TYPE_DOUBLE:\n case UPB_TYPE_FLOAT:\n \/* Standard C number parsing functions expect null-terminated strings. *\/\n if (len >= sizeof(nullz) - 1) {\n symtab_errf(ctx, \"Default too long: %.*s\", (int)len, str);\n }\n memcpy(nullz, str, len);\n nullz[len] = '\\0';\n str = nullz;\n break;\n default:\n break;\n }\n\n switch (upb_fielddef_type(f)) {\n case UPB_TYPE_INT32: {\n long val = strtol(str, &end, 0);\n if (val > INT32_MAX || val < INT32_MIN || errno == ERANGE || *end) {\n goto invalid;\n }\n f->defaultval.sint = val;\n break;\n }\n case UPB_TYPE_ENUM: {\n const upb_enumdef *e = f->sub.enumdef;\n int32_t val;\n if (!upb_enumdef_ntoi(e, str, len, &val)) {\n goto invalid;\n }\n f->defaultval.sint = val;\n break;\n }\n case UPB_TYPE_INT64: {\n \/* XXX: Need to write our own strtoll, since it's not available in c89. *\/\n int64_t val = strtol(str, &end, 0);\n if (val > INT64_MAX || val < INT64_MIN || errno == ERANGE || *end) {\n goto invalid;\n }\n f->defaultval.sint = val;\n break;\n }\n case UPB_TYPE_UINT32: {\n unsigned long val = strtoul(str, &end, 0);\n if (val > UINT32_MAX || errno == ERANGE || *end) {\n goto invalid;\n }\n f->defaultval.uint = val;\n break;\n }\n case UPB_TYPE_UINT64: {\n \/* XXX: Need to write our own strtoull, since it's not available in c89. *\/\n uint64_t val = strtoul(str, &end, 0);\n if (val > UINT64_MAX || errno == ERANGE || *end) {\n goto invalid;\n }\n f->defaultval.uint = val;\n break;\n }\n case UPB_TYPE_DOUBLE: {\n double val = strtod(str, &end);\n if (errno == ERANGE || *end) {\n goto invalid;\n }\n f->defaultval.dbl = val;\n break;\n }\n case UPB_TYPE_FLOAT: {\n \/* XXX: Need to write our own strtof, since it's not available in c89. *\/\n float val = strtod(str, &end);\n if (errno == ERANGE || *end) {\n goto invalid;\n }\n f->defaultval.flt = val;\n break;\n }\n case UPB_TYPE_BOOL: {\n if (streql2(str, len, \"false\")) {\n f->defaultval.boolean = false;\n } else if (streql2(str, len, \"true\")) {\n f->defaultval.boolean = true;\n } else {\n }\n break;\n }\n case UPB_TYPE_STRING:\n f->defaultval.str = newstr(ctx, str, len);\n break;\n case UPB_TYPE_BYTES:\n \/* XXX: need to interpret the C-escaped value. *\/\n f->defaultval.str = newstr(ctx, str, len);\n break;\n case UPB_TYPE_MESSAGE:\n \/* Should not have a default value. *\/\n symtab_errf(ctx, \"Message should not have a default (%s)\",\n upb_fielddef_fullname(f));\n }\n\n return;\n\ninvalid:\n symtab_errf(ctx, \"Invalid default '%.*s' for field %f\", (int)len, str,\n upb_fielddef_fullname(f));\n}\n\nstatic void set_default_default(symtab_addctx *ctx, upb_fielddef *f) {\n switch (upb_fielddef_type(f)) {\n case UPB_TYPE_INT32:\n case UPB_TYPE_INT64:\n case UPB_TYPE_ENUM:\n f->defaultval.sint = 0;\n break;\n case UPB_TYPE_UINT64:\n case UPB_TYPE_UINT32:\n f->defaultval.uint = 0;\n break;\n case UPB_TYPE_DOUBLE:\n case UPB_TYPE_FLOAT:\n f->defaultval.dbl = 0;\n break;\n case UPB_TYPE_STRING:\n case UPB_TYPE_BYTES:\n f->defaultval.str = newstr(ctx, NULL, 0);\n break;\n case UPB_TYPE_BOOL:\n f->defaultval.boolean = false;\n break;\n case UPB_TYPE_MESSAGE:\n break;\n }\n}\n\nstatic void create_fielddef(\n symtab_addctx *ctx, const char *prefix, upb_msgdef *m,\n const google_protobuf_FieldDescriptorProto *field_proto) {\n upb_alloc *alloc = ctx->alloc;\n upb_fielddef *f;\n const google_protobuf_FieldOptions *options;\n upb_strview name;\n const char *full_name;\n const char *json_name;\n const char *shortname;\n uint32_t field_number;\n\n if (!google_protobuf_FieldDescriptorProto_has_name(field_proto)) {\n symtab_errf(ctx, \"field has no name (%s)\", upb_msgdef_fullname(m));\n }\n\n name = google_protobuf_FieldDescriptorProto_name(field_proto);\n check_ident(ctx, name, false);\n full_name = makefullname(ctx, prefix, name);\n shortname = shortdefname(full_name);\n\n if (google_protobuf_FieldDescriptorProto_has_json_name(field_proto)) {\n json_name = strviewdup(\n ctx, google_protobuf_FieldDescriptorProto_json_name(field_proto));\n } else {\n json_name = makejsonname(ctx, shortname);\n }\n\n field_number = google_protobuf_FieldDescriptorProto_number(field_proto);\n\n if (field_number == 0 || field_number > UPB_MAX_FIELDNUMBER) {\n symtab_errf(ctx, \"invalid field number (%u)\", field_number);\n }\n\n if (m) {\n \/* direct message field. *\/\n upb_value v, field_v, json_v;\n size_t json_size;\n\n f = (upb_fielddef*)&m->fields[m->field_count++];\n f->msgdef = m;\n f->is_extension_ = false;\n\n if (upb_strtable_lookup(&m->ntof, shortname, NULL)) {\n symtab_errf(ctx, \"duplicate field name (%s)\", shortname);\n }\n\n if (upb_strtable_lookup(&m->ntof, json_name, NULL)) {\n symtab_errf(ctx, \"duplicate json_name (%s)\", json_name);\n }\n\n if (upb_inttable_lookup(&m->itof, field_number, NULL)) {\n symtab_errf(ctx, \"duplicate field number (%u)\", field_number);\n }\n\n field_v = pack_def(f, UPB_DEFTYPE_FIELD);\n json_v = pack_def(f, UPB_DEFTYPE_FIELD_JSONNAME);\n v = upb_value_constptr(f);\n json_size = strlen(json_name);\n\n CHK_OOM(\n upb_strtable_insert3(&m->ntof, name.data, name.size, field_v, alloc));\n CHK_OOM(upb_inttable_insert2(&m->itof, field_number, v, alloc));\n\n if (strcmp(shortname, json_name) != 0) {\n upb_strtable_insert3(&m->ntof, json_name, json_size, json_v, alloc);\n }\n\n if (ctx->layouts) {\n const upb_msglayout_field *fields = m->layout->fields;\n int count = m->layout->field_count;\n bool found = false;\n int i;\n for (i = 0; i < count; i++) {\n if (fields[i].number == field_number) {\n f->layout_index = i;\n found = true;\n break;\n }\n }\n UPB_ASSERT(found);\n }\n } else {\n \/* extension field. *\/\n f = (upb_fielddef*)&ctx->file->exts[ctx->file->ext_count++];\n f->is_extension_ = true;\n symtab_add(ctx, full_name, pack_def(f, UPB_DEFTYPE_FIELD));\n }\n\n f->full_name = full_name;\n f->json_name = json_name;\n f->file = ctx->file;\n f->type_ = (int)google_protobuf_FieldDescriptorProto_type(field_proto);\n f->label_ = (int)google_protobuf_FieldDescriptorProto_label(field_proto);\n f->number_ = field_number;\n f->oneof = NULL;\n f->proto3_optional_ =\n google_protobuf_FieldDescriptorProto_proto3_optional(field_proto);\n\n \/* We can't resolve the subdef or (in the case of extensions) the containing\n * message yet, because it may not have been defined yet. We stash a pointer\n * to the field_proto until later when we can properly resolve it. *\/\n f->sub.unresolved = field_proto;\n\n if (f->label_ == UPB_LABEL_REQUIRED && f->file->syntax == UPB_SYNTAX_PROTO3) {\n symtab_errf(ctx, \"proto3 fields cannot be required (%s)\", f->full_name);\n }\n\n if (google_protobuf_FieldDescriptorProto_has_oneof_index(field_proto)) {\n int oneof_index =\n google_protobuf_FieldDescriptorProto_oneof_index(field_proto);\n upb_oneofdef *oneof;\n upb_value v = upb_value_constptr(f);\n\n if (upb_fielddef_label(f) != UPB_LABEL_OPTIONAL) {\n symtab_errf(ctx, \"fields in oneof must have OPTIONAL label (%s)\",\n f->full_name);\n }\n\n if (!m) {\n symtab_errf(ctx, \"oneof_index provided for extension field (%s)\",\n f->full_name);\n }\n\n if (oneof_index >= m->oneof_count) {\n symtab_errf(ctx, \"oneof_index out of range (%s)\", f->full_name);\n }\n\n oneof = (upb_oneofdef*)&m->oneofs[oneof_index];\n f->oneof = oneof;\n\n oneof->field_count++;\n if (f->proto3_optional_) {\n oneof->synthetic = true;\n }\n CHK_OOM(upb_inttable_insert2(&oneof->itof, f->number_, v, alloc));\n CHK_OOM(upb_strtable_insert3(&oneof->ntof, name.data, name.size, v, alloc));\n } else {\n f->oneof = NULL;\n if (f->proto3_optional_) {\n symtab_errf(ctx, \"field with proto3_optional was not in a oneof (%s)\",\n f->full_name);\n }\n }\n\n options = google_protobuf_FieldDescriptorProto_has_options(field_proto) ?\n google_protobuf_FieldDescriptorProto_options(field_proto) : NULL;\n\n if (options && google_protobuf_FieldOptions_has_packed(options)) {\n f->packed_ = google_protobuf_FieldOptions_packed(options);\n } else {\n \/* Repeated fields default to packed for proto3 only. *\/\n f->packed_ = upb_fielddef_isprimitive(f) &&\n f->label_ == UPB_LABEL_REPEATED && f->file->syntax == UPB_SYNTAX_PROTO3;\n }\n\n if (options) {\n f->lazy_ = google_protobuf_FieldOptions_lazy(options);\n } else {\n f->lazy_ = false;\n }\n}\n\nstatic void create_enumdef(\n symtab_addctx *ctx, const char *prefix,\n const google_protobuf_EnumDescriptorProto *enum_proto) {\n upb_enumdef *e;\n const google_protobuf_EnumValueDescriptorProto *const *values;\n upb_strview name;\n size_t i, n;\n\n name = google_protobuf_EnumDescriptorProto_name(enum_proto);\n check_ident(ctx, name, false);\n\n e = (upb_enumdef*)&ctx->file->enums[ctx->file->enum_count++];\n e->full_name = makefullname(ctx, prefix, name);\n symtab_add(ctx, e->full_name, pack_def(e, UPB_DEFTYPE_ENUM));\n\n values = google_protobuf_EnumDescriptorProto_value(enum_proto, &n);\n CHK_OOM(upb_strtable_init2(&e->ntoi, UPB_CTYPE_INT32, n, ctx->alloc));\n CHK_OOM(upb_inttable_init2(&e->iton, UPB_CTYPE_CSTR, ctx->alloc));\n\n e->file = ctx->file;\n e->defaultval = 0;\n\n if (n == 0) {\n symtab_errf(ctx, \"enums must contain at least one value (%s)\",\n e->full_name);\n }\n\n for (i = 0; i < n; i++) {\n const google_protobuf_EnumValueDescriptorProto *value = values[i];\n upb_strview name = google_protobuf_EnumValueDescriptorProto_name(value);\n char *name2 = strviewdup(ctx, name);\n int32_t num = google_protobuf_EnumValueDescriptorProto_number(value);\n upb_value v = upb_value_int32(num);\n\n if (i == 0 && e->file->syntax == UPB_SYNTAX_PROTO3 && num != 0) {\n symtab_errf(ctx, \"for proto3, the first enum value must be zero (%s)\",\n e->full_name);\n }\n\n if (upb_strtable_lookup(&e->ntoi, name2, NULL)) {\n symtab_errf(ctx, \"duplicate enum label '%s'\", name2);\n }\n\n CHK_OOM(name2)\n CHK_OOM(\n upb_strtable_insert3(&e->ntoi, name2, strlen(name2), v, ctx->alloc));\n\n if (!upb_inttable_lookup(&e->iton, num, NULL)) {\n upb_value v = upb_value_cstr(name2);\n CHK_OOM(upb_inttable_insert2(&e->iton, num, v, ctx->alloc));\n }\n }\n\n upb_inttable_compact2(&e->iton, ctx->alloc);\n}\n\nstatic void create_msgdef(symtab_addctx *ctx, const char *prefix,\n const google_protobuf_DescriptorProto *msg_proto) {\n upb_msgdef *m;\n const google_protobuf_MessageOptions *options;\n const google_protobuf_OneofDescriptorProto *const *oneofs;\n const google_protobuf_FieldDescriptorProto *const *fields;\n const google_protobuf_EnumDescriptorProto *const *enums;\n const google_protobuf_DescriptorProto *const *msgs;\n size_t i, n_oneof, n_field, n;\n upb_strview name;\n\n name = google_protobuf_DescriptorProto_name(msg_proto);\n check_ident(ctx, name, false);\n\n m = (upb_msgdef*)&ctx->file->msgs[ctx->file->msg_count++];\n m->full_name = makefullname(ctx, prefix, name);\n symtab_add(ctx, m->full_name, pack_def(m, UPB_DEFTYPE_MSG));\n\n oneofs = google_protobuf_DescriptorProto_oneof_decl(msg_proto, &n_oneof);\n fields = google_protobuf_DescriptorProto_field(msg_proto, &n_field);\n\n CHK_OOM(upb_inttable_init2(&m->itof, UPB_CTYPE_CONSTPTR, ctx->alloc));\n CHK_OOM(upb_strtable_init2(&m->ntof, UPB_CTYPE_CONSTPTR, n_oneof + n_field,\n ctx->alloc));\n\n m->file = ctx->file;\n m->map_entry = false;\n\n options = google_protobuf_DescriptorProto_options(msg_proto);\n\n if (options) {\n m->map_entry = google_protobuf_MessageOptions_map_entry(options);\n }\n\n if (ctx->layouts) {\n m->layout = *ctx->layouts;\n ctx->layouts++;\n } else {\n \/* Allocate now (to allow cross-linking), populate later. *\/\n m->layout = symtab_alloc(\n ctx, sizeof(*m->layout) + sizeof(_upb_fasttable_entry));\n }\n\n m->oneof_count = 0;\n m->oneofs = symtab_alloc(ctx, sizeof(*m->oneofs) * n_oneof);\n for (i = 0; i < n_oneof; i++) {\n create_oneofdef(ctx, m, oneofs[i]);\n }\n\n m->field_count = 0;\n m->fields = symtab_alloc(ctx, sizeof(*m->fields) * n_field);\n for (i = 0; i < n_field; i++) {\n create_fielddef(ctx, m->full_name, m, fields[i]);\n }\n\n assign_msg_indices(ctx, m);\n finalize_oneofs(ctx, m);\n assign_msg_wellknowntype(m);\n upb_inttable_compact2(&m->itof, ctx->alloc);\n\n \/* This message is built. Now build nested messages and enums. *\/\n\n enums = google_protobuf_DescriptorProto_enum_type(msg_proto, &n);\n for (i = 0; i < n; i++) {\n create_enumdef(ctx, m->full_name, enums[i]);\n }\n\n msgs = google_protobuf_DescriptorProto_nested_type(msg_proto, &n);\n for (i = 0; i < n; i++) {\n create_msgdef(ctx, m->full_name, msgs[i]);\n }\n}\n\nstatic void count_types_in_msg(const google_protobuf_DescriptorProto *msg_proto,\n upb_filedef *file) {\n const google_protobuf_DescriptorProto *const *msgs;\n size_t i, n;\n\n file->msg_count++;\n\n msgs = google_protobuf_DescriptorProto_nested_type(msg_proto, &n);\n for (i = 0; i < n; i++) {\n count_types_in_msg(msgs[i], file);\n }\n\n google_protobuf_DescriptorProto_enum_type(msg_proto, &n);\n file->enum_count += n;\n\n google_protobuf_DescriptorProto_extension(msg_proto, &n);\n file->ext_count += n;\n}\n\nstatic void count_types_in_file(\n const google_protobuf_FileDescriptorProto *file_proto,\n upb_filedef *file) {\n const google_protobuf_DescriptorProto *const *msgs;\n size_t i, n;\n\n msgs = google_protobuf_FileDescriptorProto_message_type(file_proto, &n);\n for (i = 0; i < n; i++) {\n count_types_in_msg(msgs[i], file);\n }\n\n google_protobuf_FileDescriptorProto_enum_type(file_proto, &n);\n file->enum_count += n;\n\n google_protobuf_FileDescriptorProto_extension(file_proto, &n);\n file->ext_count += n;\n}\n\nstatic void resolve_fielddef(symtab_addctx *ctx, const char *prefix,\n upb_fielddef *f) {\n upb_strview name;\n const google_protobuf_FieldDescriptorProto *field_proto = f->sub.unresolved;\n\n if (f->is_extension_) {\n if (!google_protobuf_FieldDescriptorProto_has_extendee(field_proto)) {\n symtab_errf(ctx, \"extension for field '%s' had no extendee\",\n f->full_name);\n }\n\n name = google_protobuf_FieldDescriptorProto_extendee(field_proto);\n f->msgdef = symtab_resolve(ctx, f, prefix, name, UPB_DEFTYPE_MSG);\n }\n\n if ((upb_fielddef_issubmsg(f) || f->type_ == UPB_DESCRIPTOR_TYPE_ENUM) &&\n !google_protobuf_FieldDescriptorProto_has_type_name(field_proto)) {\n symtab_errf(ctx, \"field '%s' is missing type name\", f->full_name);\n }\n\n name = google_protobuf_FieldDescriptorProto_type_name(field_proto);\n\n if (upb_fielddef_issubmsg(f)) {\n f->sub.msgdef = symtab_resolve(ctx, f, prefix, name, UPB_DEFTYPE_MSG);\n } else if (f->type_ == UPB_DESCRIPTOR_TYPE_ENUM) {\n f->sub.enumdef = symtab_resolve(ctx, f, prefix, name, UPB_DEFTYPE_ENUM);\n }\n\n \/* Have to delay resolving of the default value until now because of the enum\n * case, since enum defaults are specified with a label. *\/\n if (google_protobuf_FieldDescriptorProto_has_default_value(field_proto)) {\n upb_strview defaultval =\n google_protobuf_FieldDescriptorProto_default_value(field_proto);\n\n if (f->file->syntax == UPB_SYNTAX_PROTO3) {\n symtab_errf(ctx, \"proto3 fields cannot have explicit defaults (%s)\",\n f->full_name);\n }\n\n if (upb_fielddef_issubmsg(f)) {\n symtab_errf(ctx, \"message fields cannot have explicit defaults (%s)\",\n f->full_name);\n }\n\n parse_default(ctx, defaultval.data, defaultval.size, f);\n } else {\n set_default_default(ctx, f);\n }\n}\n\nstatic void build_filedef(\n symtab_addctx *ctx, upb_filedef *file,\n const google_protobuf_FileDescriptorProto *file_proto) {\n const google_protobuf_FileOptions *file_options_proto;\n const google_protobuf_DescriptorProto *const *msgs;\n const google_protobuf_EnumDescriptorProto *const *enums;\n const google_protobuf_FieldDescriptorProto *const *exts;\n const upb_strview* strs;\n size_t i, n;\n\n count_types_in_file(file_proto, file);\n\n file->msgs = symtab_alloc(ctx, sizeof(*file->msgs) * file->msg_count);\n file->enums = symtab_alloc(ctx, sizeof(*file->enums) * file->enum_count);\n file->exts = symtab_alloc(ctx, sizeof(*file->exts) * file->ext_count);\n\n \/* We increment these as defs are added. *\/\n file->msg_count = 0;\n file->enum_count = 0;\n file->ext_count = 0;\n\n if (!google_protobuf_FileDescriptorProto_has_name(file_proto)) {\n symtab_errf(ctx, \"File has no name\");\n }\n\n file->name =\n strviewdup(ctx, google_protobuf_FileDescriptorProto_name(file_proto));\n file->phpprefix = NULL;\n file->phpnamespace = NULL;\n\n if (google_protobuf_FileDescriptorProto_has_package(file_proto)) {\n upb_strview package =\n google_protobuf_FileDescriptorProto_package(file_proto);\n check_ident(ctx, package, true);\n file->package = strviewdup(ctx, package);\n } else {\n file->package = NULL;\n }\n\n if (google_protobuf_FileDescriptorProto_has_syntax(file_proto)) {\n upb_strview syntax =\n google_protobuf_FileDescriptorProto_syntax(file_proto);\n\n if (streql_view(syntax, \"proto2\")) {\n file->syntax = UPB_SYNTAX_PROTO2;\n } else if (streql_view(syntax, \"proto3\")) {\n file->syntax = UPB_SYNTAX_PROTO3;\n } else {\n symtab_errf(ctx, \"Invalid syntax '\" UPB_STRVIEW_FORMAT \"'\",\n UPB_STRVIEW_ARGS(syntax));\n }\n } else {\n file->syntax = UPB_SYNTAX_PROTO2;\n }\n\n \/* Read options. *\/\n file_options_proto = google_protobuf_FileDescriptorProto_options(file_proto);\n if (file_options_proto) {\n if (google_protobuf_FileOptions_has_php_class_prefix(file_options_proto)) {\n file->phpprefix = strviewdup(\n ctx,\n google_protobuf_FileOptions_php_class_prefix(file_options_proto));\n }\n if (google_protobuf_FileOptions_has_php_namespace(file_options_proto)) {\n file->phpnamespace = strviewdup(\n ctx, google_protobuf_FileOptions_php_namespace(file_options_proto));\n }\n }\n\n \/* Verify dependencies. *\/\n strs = google_protobuf_FileDescriptorProto_dependency(file_proto, &n);\n file->deps = symtab_alloc(ctx, sizeof(*file->deps) * n);\n\n for (i = 0; i < n; i++) {\n upb_strview dep_name = strs[i];\n upb_value v;\n if (!upb_strtable_lookup2(&ctx->symtab->files, dep_name.data,\n dep_name.size, &v)) {\n symtab_errf(ctx,\n \"Depends on file '\" UPB_STRVIEW_FORMAT\n \"', but it has not been loaded\",\n UPB_STRVIEW_ARGS(dep_name));\n }\n file->deps[i] = upb_value_getconstptr(v);\n }\n\n \/* Create messages. *\/\n msgs = google_protobuf_FileDescriptorProto_message_type(file_proto, &n);\n for (i = 0; i < n; i++) {\n create_msgdef(ctx, file->package, msgs[i]);\n }\n\n \/* Create enums. *\/\n enums = google_protobuf_FileDescriptorProto_enum_type(file_proto, &n);\n for (i = 0; i < n; i++) {\n create_enumdef(ctx, file->package, enums[i]);\n }\n\n \/* Create extensions. *\/\n exts = google_protobuf_FileDescriptorProto_extension(file_proto, &n);\n file->exts = symtab_alloc(ctx, sizeof(*file->exts) * n);\n for (i = 0; i < n; i++) {\n create_fielddef(ctx, file->package, NULL, exts[i]);\n }\n\n \/* Now that all names are in the table, build layouts and resolve refs. *\/\n for (i = 0; i < (size_t)file->ext_count; i++) {\n resolve_fielddef(ctx, file->package, (upb_fielddef*)&file->exts[i]);\n }\n\n for (i = 0; i < (size_t)file->msg_count; i++) {\n const upb_msgdef *m = &file->msgs[i];\n int j;\n for (j = 0; j < m->field_count; j++) {\n resolve_fielddef(ctx, m->full_name, (upb_fielddef*)&m->fields[j]);\n }\n }\n\n if (!ctx->layouts) {\n for (i = 0; i < (size_t)file->msg_count; i++) {\n const upb_msgdef *m = &file->msgs[i];\n make_layout(ctx, m);\n }\n }\n}\n\nstatic void remove_filedef(upb_symtab *s, upb_filedef *file) {\n upb_alloc *alloc = upb_arena_alloc(s->arena);\n int i;\n for (i = 0; i < file->msg_count; i++) {\n const char *name = file->msgs[i].full_name;\n upb_strtable_remove3(&s->syms, name, strlen(name), NULL, alloc);\n }\n for (i = 0; i < file->enum_count; i++) {\n const char *name = file->enums[i].full_name;\n upb_strtable_remove3(&s->syms, name, strlen(name), NULL, alloc);\n }\n for (i = 0; i < file->ext_count; i++) {\n const char *name = file->exts[i].full_name;\n upb_strtable_remove3(&s->syms, name, strlen(name), NULL, alloc);\n }\n}\n\nstatic const upb_filedef *_upb_symtab_addfile(\n upb_symtab *s, const google_protobuf_FileDescriptorProto *file_proto,\n const upb_msglayout **layouts, upb_status *status) {\n upb_arena *file_arena = upb_arena_new();\n upb_filedef *file;\n symtab_addctx ctx;\n\n if (!file_arena) return NULL;\n\n file = upb_arena_malloc(file_arena, sizeof(*file));\n if (!file) goto done;\n\n ctx.file = file;\n ctx.symtab = s;\n ctx.file_arena = file_arena;\n ctx.alloc = upb_arena_alloc(file_arena);\n ctx.layouts = layouts;\n ctx.status = status;\n\n file->msg_count = 0;\n file->enum_count = 0;\n file->ext_count = 0;\n\n if (UPB_UNLIKELY(UPB_SETJMP(ctx.err))) {\n UPB_ASSERT(!upb_ok(status));\n remove_filedef(s, file);\n file = NULL;\n } else {\n build_filedef(&ctx, file, file_proto);\n upb_strtable_insert3(&s->files, file->name, strlen(file->name),\n upb_value_constptr(file), ctx.alloc);\n UPB_ASSERT(upb_ok(status));\n upb_arena_fuse(s->arena, file_arena);\n }\n\ndone:\n upb_arena_free(file_arena);\n return file;\n}\n\nconst upb_filedef *upb_symtab_addfile(\n upb_symtab *s, const google_protobuf_FileDescriptorProto *file_proto,\n upb_status *status) {\n return _upb_symtab_addfile(s, file_proto, NULL, status);\n}\n\n\/* Include here since we want most of this file to be stdio-free. *\/\n#include \n\nbool _upb_symtab_loaddefinit(upb_symtab *s, const upb_def_init *init) {\n \/* Since this function should never fail (it would indicate a bug in upb) we\n * print errors to stderr instead of returning error status to the user. *\/\n upb_def_init **deps = init->deps;\n google_protobuf_FileDescriptorProto *file;\n upb_arena *arena;\n upb_status status;\n\n upb_status_clear(&status);\n\n if (upb_strtable_lookup(&s->files, init->filename, NULL)) {\n return true;\n }\n\n arena = upb_arena_new();\n\n for (; *deps; deps++) {\n if (!_upb_symtab_loaddefinit(s, *deps)) goto err;\n }\n\n file = google_protobuf_FileDescriptorProto_parse_ex(\n init->descriptor.data, init->descriptor.size, arena, UPB_DECODE_ALIAS);\n s->bytes_loaded += init->descriptor.size;\n\n if (!file) {\n upb_status_seterrf(\n &status,\n \"Failed to parse compiled-in descriptor for file '%s'. This should \"\n \"never happen.\",\n init->filename);\n goto err;\n }\n\n if (!_upb_symtab_addfile(s, file, init->layouts, &status)) goto err;\n\n upb_arena_free(arena);\n return true;\n\nerr:\n fprintf(stderr, \"Error loading compiled-in descriptor: %s\\n\",\n upb_status_errmsg(&status));\n upb_arena_free(arena);\n return false;\n}\n\nsize_t _upb_symtab_bytesloaded(const upb_symtab *s) {\n return s->bytes_loaded;\n}\n\n#undef CHK_OOM\n","avg_line_length":29.379659457,"max_line_length":85,"alphanum_fraction":0.6759186742} +{"size":828,"ext":"h","lang":"C","max_stars_count":null,"content":"\nunsigned char string_txt[] = {\n\n 0x72, 0x62, 0x0a, 0x77, 0x62, 0x0a, 0x2f, 0x74, 0x6d, 0x70, 0x2f, 0x74,\n 0x65, 0x6d, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x0a, 0x2f,\n 0x74, 0x6d, 0x70, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x2f, 0x6e, 0x30, 0x0a,\n 0x2f, 0x74, 0x6d, 0x70, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x2f, 0x6e, 0x31,\n 0x0a, 0x2f, 0x74, 0x6d, 0x70, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x2f, 0x6e,\n 0x32, 0x0a, 0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x68, 0x20, 0x2f, 0x74,\n 0x6d, 0x70, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66,\n 0x69, 0x67, 0x0a, 0x23, 0x65, 0x6e, 0x64, 0x0a, 0x23, 0x71, 0x75, 0x69,\n 0x74, 0x0a, 0x23, 0x64, 0x6f, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x65, 0x64,\n 0x69, 0x74, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x66, 0x69, 0x6c, 0x65,\n 0x0a, 0x0a\n\n};\n\nunsigned int string_txt_len = 122;\n\n\n","avg_line_length":39.4285714286,"max_line_length":73,"alphanum_fraction":0.6497584541} +{"size":1503,"ext":"h","lang":"C","max_stars_count":null,"content":"\ufeff#pragma once\n\r\n#include \"il2cpp-config.h\"\n\r\n#ifndef _MSC_VER\r\n# include \r\n#else\r\n# include \r\n#endif\r\n\r\n#include \r\n\r\n#include \"mscorlib_System_ValueType3640485471.h\"\r\n\r\n\/\/ System.Array\r\nstruct Il2CppArray;\r\n\r\n\r\n\r\n\r\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Winvalid-offsetof\"\n#pragma clang diagnostic ignored \"-Wunused-variable\"\n#endif\n\n\/\/ System.Array\/InternalEnumerator`1>\nstruct InternalEnumerator_1_t2597342899 \n{\npublic:\n\t\/\/ System.Array System.Array\/InternalEnumerator`1::array\n\tIl2CppArray * ___array_0;\n\t\/\/ System.Int32 System.Array\/InternalEnumerator`1::idx\n\tint32_t ___idx_1;\n\npublic:\n\tinline static int32_t get_offset_of_array_0() { return static_cast(offsetof(InternalEnumerator_1_t2597342899, ___array_0)); }\n\tinline Il2CppArray * get_array_0() const { return ___array_0; }\n\tinline Il2CppArray ** get_address_of_array_0() { return &___array_0; }\n\tinline void set_array_0(Il2CppArray * value)\n\t{\n\t\t___array_0 = value;\n\t\tIl2CppCodeGenWriteBarrier(&___array_0, value);\n\t}\n\n\tinline static int32_t get_offset_of_idx_1() { return static_cast(offsetof(InternalEnumerator_1_t2597342899, ___idx_1)); }\n\tinline int32_t get_idx_1() const { return ___idx_1; }\n\tinline int32_t* get_address_of_idx_1() { return &___idx_1; }\n\tinline void set_idx_1(int32_t value)\n\t{\n\t\t___idx_1 = value;\n\t}\n};\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n","avg_line_length":25.9137931034,"max_line_length":135,"alphanum_fraction":0.7704590818} +{"size":230,"ext":"h","lang":"C","max_stars_count":2.0,"content":"#import \"Foundation\/Foundation.h\"\n#import \"LibC\/LibC-Swift.h\"\n#import \"LibB\/LibB.h\"\n\n@interface LibDObject : NSObject\n\n@property(nonatomic, assign) LibCEnumeration example;\n\n@property(nonatomic, assign) LibBClass *example2;\n\n@end\n","avg_line_length":19.1666666667,"max_line_length":53,"alphanum_fraction":0.7695652174} +{"size":16867,"ext":"c","lang":"C","max_stars_count":null,"content":"\/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *\/\n\n#include \n\n#include \n#include \n#include \n#include \n#include \n\n#include \n\n#include \"android_native_app_glue.h\"\n#include \"..\/logger.h\"\n\n#define TAG \"[NativeGlue]\"\n\n#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOGGER_NAME, __VA_ARGS__))\n\n#ifndef NDEBUG\n# define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOGGER_NAME, __VA_ARGS__))\n#else\n# define LOGD(...) ((void)0)\n#endif\n\nstatic void free_saved_state(struct android_app* android_app) {\n pthread_mutex_lock(&android_app->mutex);\n if (android_app->savedState != NULL) {\n free(android_app->savedState);\n android_app->savedState = NULL;\n android_app->savedStateSize = 0;\n }\n pthread_mutex_unlock(&android_app->mutex);\n}\n\nint8_t android_app_read_cmd(struct android_app* android_app) {\n int8_t cmd;\n if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd)) {\n switch (cmd) {\n case APP_CMD_SAVE_STATE:\n free_saved_state(android_app);\n break;\n }\n return cmd;\n } else {\n LOGE(\"%s: No data on command pipe!\", TAG);\n }\n return -1;\n}\n\n\n\/*static void print_cur_config(struct android_app* android_app) {\n char lang[2], country[2];\n AConfiguration_getLanguage(android_app->config, lang);\n AConfiguration_getCountry(android_app->config, country);\n\n LOGD(\"%s: Config: mcc=%d mnc=%d lang=%c%c cnt=%c%c orien=%d touch=%d dens=%d \"\n \"keys=%d nav=%d keysHid=%d navHid=%d sdk=%d size=%d long=%d \"\n \"modetype=%d modenight=%d\", TAG,\n AConfiguration_getMcc(android_app->config),\n AConfiguration_getMnc(android_app->config),\n lang[0], lang[1], country[0], country[1],\n AConfiguration_getOrientation(android_app->config),\n AConfiguration_getTouchscreen(android_app->config),\n AConfiguration_getDensity(android_app->config),\n AConfiguration_getKeyboard(android_app->config),\n AConfiguration_getNavigation(android_app->config),\n AConfiguration_getKeysHidden(android_app->config),\n AConfiguration_getNavHidden(android_app->config),\n AConfiguration_getSdkVersion(android_app->config),\n AConfiguration_getScreenSize(android_app->config),\n AConfiguration_getScreenLong(android_app->config),\n AConfiguration_getUiModeType(android_app->config),\n AConfiguration_getUiModeNight(android_app->config));\n}*\/\n\nvoid android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd) {\n switch (cmd) {\n case APP_CMD_INPUT_CHANGED:\n LOGD(\"%s: APP_CMD_INPUT_CHANGED\\n\", TAG);\n pthread_mutex_lock(&android_app->mutex);\n if (android_app->inputQueue != NULL) {\n AInputQueue_detachLooper(android_app->inputQueue);\n }\n android_app->inputQueue = android_app->pendingInputQueue;\n if (android_app->inputQueue != NULL) {\n LOGD(\"%s: Attaching input queue to looper\", TAG);\n AInputQueue_attachLooper(android_app->inputQueue,\n android_app->looper, LOOPER_ID_INPUT, NULL,\n &android_app->inputPollSource);\n }\n pthread_cond_broadcast(&android_app->cond);\n pthread_mutex_unlock(&android_app->mutex);\n break;\n\n case APP_CMD_INIT_WINDOW:\n LOGD(\"%s: APP_CMD_INIT_WINDOW\\n\", TAG);\n pthread_mutex_lock(&android_app->mutex);\n android_app->window = android_app->pendingWindow;\n pthread_cond_broadcast(&android_app->cond);\n pthread_mutex_unlock(&android_app->mutex);\n break;\n\n case APP_CMD_TERM_WINDOW:\n LOGD(\"%s: APP_CMD_TERM_WINDOW\\n\", TAG);\n pthread_cond_broadcast(&android_app->cond);\n break;\n\n case APP_CMD_RESUME:\n case APP_CMD_START:\n case APP_CMD_PAUSE:\n case APP_CMD_STOP:\n LOGD(\"%s: activityState=%d\\n\", TAG, cmd);\n pthread_mutex_lock(&android_app->mutex);\n android_app->activityState = cmd;\n pthread_cond_broadcast(&android_app->cond);\n pthread_mutex_unlock(&android_app->mutex);\n break;\n\n case APP_CMD_CONFIG_CHANGED:\n LOGD(\"%s: APP_CMD_CONFIG_CHANGED\\n\", TAG);\n AConfiguration_fromAssetManager(android_app->config,\n android_app->activity->assetManager);\n \/\/print_cur_config(android_app);\n break;\n\n case APP_CMD_DESTROY:\n LOGD(\"%s: APP_CMD_DESTROY\\n\", TAG);\n android_app->destroyRequested = 1;\n break;\n }\n}\n\nvoid android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd) {\n switch (cmd) {\n case APP_CMD_TERM_WINDOW:\n LOGD(\"%s: APP_CMD_TERM_WINDOW\\n\", TAG);\n pthread_mutex_lock(&android_app->mutex);\n android_app->window = NULL;\n pthread_cond_broadcast(&android_app->cond);\n pthread_mutex_unlock(&android_app->mutex);\n break;\n\n case APP_CMD_SAVE_STATE:\n LOGD(\"%s: APP_CMD_SAVE_STATE\\n\", TAG);\n pthread_mutex_lock(&android_app->mutex);\n android_app->stateSaved = 1;\n pthread_cond_broadcast(&android_app->cond);\n pthread_mutex_unlock(&android_app->mutex);\n break;\n\n case APP_CMD_RESUME:\n free_saved_state(android_app);\n break;\n }\n}\n\n\/*void app_dummy(void) {\n\n}*\/\n\nstatic void android_app_destroy(struct android_app* android_app) {\n LOGD(\"%s: android_app_destroy!\", TAG);\n free_saved_state(android_app);\n pthread_mutex_lock(&android_app->mutex);\n if (android_app->inputQueue != NULL) {\n AInputQueue_detachLooper(android_app->inputQueue);\n }\n AConfiguration_delete(android_app->config);\n android_app->destroyed = 1;\n pthread_cond_broadcast(&android_app->cond);\n pthread_mutex_unlock(&android_app->mutex);\n \/\/ Can't touch android_app object after this.\n}\n\nstatic void process_input(struct android_app* app, struct android_poll_source* source) {\n AInputEvent* event = NULL;\n while (AInputQueue_getEvent(app->inputQueue, &event) >= 0) {\n LOGD(\"%s: New input event: type=%d\\n\", TAG, AInputEvent_getType(event));\n if (AInputQueue_preDispatchEvent(app->inputQueue, event)) {\n continue;\n }\n int32_t handled = 0;\n if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event);\n AInputQueue_finishEvent(app->inputQueue, event, handled);\n }\n}\n\nstatic void process_cmd(struct android_app* app, struct android_poll_source* source) {\n int8_t cmd = android_app_read_cmd(app);\n android_app_pre_exec_cmd(app, cmd);\n if (app->onAppCmd != NULL) app->onAppCmd(app, cmd);\n android_app_post_exec_cmd(app, cmd);\n}\n\nstatic void* android_app_entry(void* param) {\n struct android_app* android_app = (struct android_app*)param;\n\n android_app->config = AConfiguration_new();\n AConfiguration_fromAssetManager(android_app->config, android_app->activity->assetManager);\n\n \/\/print_cur_config(android_app);\n\n android_app->cmdPollSource.id = LOOPER_ID_MAIN;\n android_app->cmdPollSource.app = android_app;\n android_app->cmdPollSource.process = process_cmd;\n android_app->inputPollSource.id = LOOPER_ID_INPUT;\n android_app->inputPollSource.app = android_app;\n android_app->inputPollSource.process = process_input;\n\n ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);\n ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN, ALOOPER_EVENT_INPUT, NULL,\n &android_app->cmdPollSource);\n android_app->looper = looper;\n\n pthread_mutex_lock(&android_app->mutex);\n android_app->running = 1;\n pthread_cond_broadcast(&android_app->cond);\n pthread_mutex_unlock(&android_app->mutex);\n\n android_main(android_app);\n\n android_app_destroy(android_app);\n return NULL;\n}\n\n\/\/ --------------------------------------------------------------------\n\/\/ Native activity interaction (called from main thread)\n\/\/ --------------------------------------------------------------------\n\nstatic struct android_app* android_app_create(ANativeActivity* activity,\n void* savedState, size_t savedStateSize) {\n struct android_app* android_app = (struct android_app*)malloc(sizeof(struct android_app));\n memset(android_app, 0, sizeof(struct android_app));\n android_app->activity = activity;\n\n pthread_mutex_init(&android_app->mutex, NULL);\n pthread_cond_init(&android_app->cond, NULL);\n\n if (savedState != NULL) {\n android_app->savedState = malloc(savedStateSize);\n android_app->savedStateSize = savedStateSize;\n memcpy(android_app->savedState, savedState, savedStateSize);\n }\n\n int msgpipe[2];\n if (pipe(msgpipe)) {\n LOGE(\"%s: could not create pipe: %s\", TAG, strerror(errno));\n return NULL;\n }\n android_app->msgread = msgpipe[0];\n android_app->msgwrite = msgpipe[1];\n\n pthread_attr_t attr;\n pthread_attr_init(&attr);\n pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);\n pthread_create(&android_app->thread, &attr, android_app_entry, android_app);\n\n \/\/ Wait for thread to start.\n pthread_mutex_lock(&android_app->mutex);\n while (!android_app->running) {\n pthread_cond_wait(&android_app->cond, &android_app->mutex);\n }\n pthread_mutex_unlock(&android_app->mutex);\n\n return android_app;\n}\n\nstatic void android_app_write_cmd(struct android_app* android_app, int8_t cmd) {\n if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd)) {\n LOGE(\"%s: Failure writing android_app cmd: %s\\n\", TAG, strerror(errno));\n }\n}\n\nstatic void android_app_set_input(struct android_app* android_app, AInputQueue* inputQueue) {\n pthread_mutex_lock(&android_app->mutex);\n android_app->pendingInputQueue = inputQueue;\n android_app_write_cmd(android_app, APP_CMD_INPUT_CHANGED);\n while (android_app->inputQueue != android_app->pendingInputQueue) {\n pthread_cond_wait(&android_app->cond, &android_app->mutex);\n }\n pthread_mutex_unlock(&android_app->mutex);\n}\n\nstatic void android_app_set_window(struct android_app* android_app, ANativeWindow* window) {\n pthread_mutex_lock(&android_app->mutex);\n if (android_app->pendingWindow != NULL) {\n android_app_write_cmd(android_app, APP_CMD_TERM_WINDOW);\n }\n android_app->pendingWindow = window;\n if (window != NULL) {\n android_app_write_cmd(android_app, APP_CMD_INIT_WINDOW);\n }\n while (android_app->window != android_app->pendingWindow) {\n pthread_cond_wait(&android_app->cond, &android_app->mutex);\n }\n pthread_mutex_unlock(&android_app->mutex);\n}\n\nstatic void android_app_set_activity_state(struct android_app* android_app, int8_t cmd) {\n pthread_mutex_lock(&android_app->mutex);\n android_app_write_cmd(android_app, cmd);\n while (android_app->activityState != cmd) {\n pthread_cond_wait(&android_app->cond, &android_app->mutex);\n }\n pthread_mutex_unlock(&android_app->mutex);\n}\n\nstatic void android_app_free(struct android_app* android_app) {\n pthread_mutex_lock(&android_app->mutex);\n android_app_write_cmd(android_app, APP_CMD_DESTROY);\n while (!android_app->destroyed) {\n pthread_cond_wait(&android_app->cond, &android_app->mutex);\n }\n pthread_mutex_unlock(&android_app->mutex);\n\n close(android_app->msgread);\n close(android_app->msgwrite);\n pthread_cond_destroy(&android_app->cond);\n pthread_mutex_destroy(&android_app->mutex);\n free(android_app);\n}\n\nstatic void onDestroy(ANativeActivity* activity) {\n LOGD(\"%s: Destroy: %p\\n\", TAG, activity);\n android_app_free((struct android_app*)activity->instance);\n}\n\nstatic void onStart(ANativeActivity* activity) {\n LOGD(\"%s: Start: %p\\n\", TAG, activity);\n android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_START);\n}\n\nstatic void onResume(ANativeActivity* activity) {\n LOGD(\"%s: Resume: %p\\n\", TAG, activity);\n android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_RESUME);\n}\n\nstatic void* onSaveInstanceState(ANativeActivity* activity, size_t* outLen) {\n struct android_app* android_app = (struct android_app*)activity->instance;\n void* savedState = NULL;\n\n LOGD(\"%s: SaveInstanceState: %p\\n\", TAG, activity);\n pthread_mutex_lock(&android_app->mutex);\n android_app->stateSaved = 0;\n android_app_write_cmd(android_app, APP_CMD_SAVE_STATE);\n while (!android_app->stateSaved) {\n pthread_cond_wait(&android_app->cond, &android_app->mutex);\n }\n\n if (android_app->savedState != NULL) {\n savedState = android_app->savedState;\n *outLen = android_app->savedStateSize;\n android_app->savedState = NULL;\n android_app->savedStateSize = 0;\n }\n\n pthread_mutex_unlock(&android_app->mutex);\n\n return savedState;\n}\n\nstatic void onPause(ANativeActivity* activity) {\n LOGD(\"%s: Pause: %p\\n\", TAG, activity);\n android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_PAUSE);\n}\n\nstatic void onStop(ANativeActivity* activity) {\n LOGD(\"%s: Stop: %p\\n\", TAG, activity);\n android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_STOP);\n}\n\nstatic void onConfigurationChanged(ANativeActivity* activity) {\n struct android_app* android_app = (struct android_app*)activity->instance;\n LOGD(\"%s: ConfigurationChanged: %p\\n\", TAG, activity);\n android_app_write_cmd(android_app, APP_CMD_CONFIG_CHANGED);\n}\n\nstatic void onLowMemory(ANativeActivity* activity) {\n struct android_app* android_app = (struct android_app*)activity->instance;\n LOGD(\"%s: LowMemory: %p\\n\", TAG, activity);\n android_app_write_cmd(android_app, APP_CMD_LOW_MEMORY);\n}\n\nstatic void onWindowFocusChanged(ANativeActivity* activity, int focused) {\n LOGD(\"%s: WindowFocusChanged: %p -- %d\\n\", TAG, activity, focused);\n android_app_write_cmd((struct android_app*)activity->instance,\n focused ? APP_CMD_GAINED_FOCUS : APP_CMD_LOST_FOCUS);\n}\n\nstatic void onNativeWindowCreated(ANativeActivity* activity, ANativeWindow* window) {\n LOGD(\"%s: NativeWindowCreated: %p -- %p\\n\", TAG, activity, window);\n android_app_set_window((struct android_app*)activity->instance, window);\n}\n\nstatic void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* window) {\n LOGD(\"%s: NativeWindowDestroyed: %p -- %p\\n\", TAG, activity, window);\n android_app_set_window((struct android_app*)activity->instance, NULL);\n}\n\nstatic void onInputQueueCreated(ANativeActivity* activity, AInputQueue* queue) {\n LOGD(\"%s: InputQueueCreated: %p -- %p\\n\", TAG, activity, queue);\n android_app_set_input((struct android_app*)activity->instance, queue);\n}\n\nstatic void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue) {\n LOGD(\"%s: InputQueueDestroyed: %p -- %p\\n\", TAG, activity, queue);\n android_app_set_input((struct android_app*)activity->instance, NULL);\n}\n\n__attribute__((visibility(\"default\"))) void ANativeActivity_onCreate(ANativeActivity* activity,\n void* savedState, size_t savedStateSize) {\n LOGD(\"%s: Creating: %p\\n\", TAG, activity);\n activity->callbacks->onDestroy = onDestroy;\n activity->callbacks->onStart = onStart;\n activity->callbacks->onResume = onResume;\n activity->callbacks->onSaveInstanceState = onSaveInstanceState;\n activity->callbacks->onPause = onPause;\n activity->callbacks->onStop = onStop;\n activity->callbacks->onConfigurationChanged = onConfigurationChanged;\n activity->callbacks->onLowMemory = onLowMemory;\n activity->callbacks->onWindowFocusChanged = onWindowFocusChanged;\n activity->callbacks->onNativeWindowCreated = onNativeWindowCreated;\n activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyed;\n activity->callbacks->onInputQueueCreated = onInputQueueCreated;\n activity->callbacks->onInputQueueDestroyed = onInputQueueDestroyed;\n\n activity->instance = android_app_create(activity, savedState, savedStateSize);\n}\n","avg_line_length":37.9033707865,"max_line_length":95,"alphanum_fraction":0.6894527776} +{"size":4667,"ext":"h","lang":"C","max_stars_count":139.0,"content":"\/\/\n\/\/ HPTextView.h\n\/\/\n\/\/ Created by Hans Pinckaers on 29-06-10.\n\/\/\n\/\/\tMIT License\n\/\/\n\/\/\tCopyright (c) 2011 Hans Pinckaers\n\/\/\n\/\/\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\/\/\tof this software and associated documentation files (the \"Software\"), to deal\n\/\/\tin the Software without restriction, including without limitation the rights\n\/\/\tto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\n\/\/\tcopies of the Software, and to permit persons to whom the Software is\n\/\/\tfurnished to do so, subject to the following conditions:\n\/\/\n\/\/\tThe above copyright notice and this permission notice shall be included in\n\/\/\tall copies or substantial portions of the Software.\n\/\/\n\/\/\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\/\/\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\/\/\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\/\/\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\/\/\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\/\/\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\/\/\tTHE SOFTWARE.\n\n#import \n\n#if __IPHONE_OS_VERSION_MAX_ALLOWED < 60000\n\t\/\/ UITextAlignment is deprecated in iOS 6.0+, use NSTextAlignment instead.\n\t\/\/ Reference: https:\/\/developer.apple.com\/library\/ios\/documentation\/uikit\/reference\/NSString_UIKit_Additions\/Reference\/Reference.html\n\t#define NSTextAlignment UITextAlignment\n#endif\n\n@class HSGrowingTextView;\n@class HSTextViewInternal;\n\n@protocol HPGrowingTextViewDelegate\n\n@optional\n- (BOOL)growingTextViewShouldBeginEditing:(HSGrowingTextView *)growingTextView;\n- (BOOL)growingTextViewShouldEndEditing:(HSGrowingTextView *)growingTextView;\n\n- (void)growingTextViewDidBeginEditing:(HSGrowingTextView *)growingTextView;\n- (void)growingTextViewDidEndEditing:(HSGrowingTextView *)growingTextView;\n\n- (BOOL)growingTextView:(HSGrowingTextView *)growingTextView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;\n- (void)growingTextViewDidChange:(HSGrowingTextView *)growingTextView;\n\n- (void)growingTextView:(HSGrowingTextView *)growingTextView willChangeHeight:(float)height;\n- (void)growingTextView:(HSGrowingTextView *)growingTextView didChangeHeight:(float)height;\n\n- (void)growingTextViewDidChangeSelection:(HSGrowingTextView *)growingTextView;\n- (BOOL)growingTextViewShouldReturn:(HSGrowingTextView *)growingTextView;\n\n@end\n\n@interface HSGrowingTextView : UIView {\n\tHSTextViewInternal *internalTextView;\t\n\t\n\tint minHeight;\n\tint maxHeight;\n\t\n\t\/\/class properties\n\tint maxNumberOfLines;\n\tint minNumberOfLines;\n\t\n\tBOOL animateHeightChange;\n NSTimeInterval animationDuration;\n\t\n\t\/\/uitextview properties\n\tNSObject *__unsafe_unretained delegate;\n\tNSTextAlignment textAlignment;\n\tNSRange selectedRange;\n\tBOOL editable;\n\tUIDataDetectorTypes dataDetectorTypes;\n\tUIReturnKeyType returnKeyType;\n\tUIKeyboardType keyboardType;\n \n UIEdgeInsets contentInset;\n}\n\n\/\/real class properties\n@property int maxNumberOfLines;\n@property int minNumberOfLines;\n@property (nonatomic) int maxHeight;\n@property (nonatomic) int minHeight;\n@property BOOL animateHeightChange;\n@property NSTimeInterval animationDuration;\n@property (nonatomic, strong) NSString *placeholder;\n@property (nonatomic, strong) UIColor *placeholderColor;\n@property (nonatomic, strong) UITextView *internalTextView;\t\n\n\n\/\/uitextview properties\n@property(unsafe_unretained) NSObject *delegate;\n@property(nonatomic,strong) NSString *text;\n@property(nonatomic,strong) UIFont *font;\n@property(nonatomic,strong) UIColor *textColor;\n@property(nonatomic) NSTextAlignment textAlignment; \/\/ default is NSTextAlignmentLeft\n@property(nonatomic) NSRange selectedRange; \/\/ only ranges of length 0 are supported\n@property(nonatomic,getter=isEditable) BOOL editable;\n@property(nonatomic) UIDataDetectorTypes dataDetectorTypes __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_3_0);\n@property (nonatomic) UIReturnKeyType returnKeyType;\n@property (nonatomic) UIKeyboardType keyboardType;\n@property (assign) UIEdgeInsets contentInset;\n@property (nonatomic) BOOL isScrollable;\n@property(nonatomic) BOOL enablesReturnKeyAutomatically;\n\n\/\/uitextview methods\n\/\/need others? use .internalTextView\n- (BOOL)becomeFirstResponder;\n- (BOOL)resignFirstResponder;\n- (BOOL)isFirstResponder;\n\n- (BOOL)hasText;\n- (void)scrollRangeToVisible:(NSRange)range;\n\n\/\/ call to force a height change (e.g. after you change max\/min lines)\n- (void)refreshHeight;\n- (void)refreshFrame:(CGRect)newFrame;\n\n@end\n","avg_line_length":37.336,"max_line_length":134,"alphanum_fraction":0.8017998714} +{"size":5294,"ext":"h","lang":"C","max_stars_count":null,"content":"#pragma once\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nnamespace torch {\nnamespace lazy {\n\nstruct TorchScriptIrBuilder : IrBuilder {\n NodePtr MakeDeviceData(\n const std::shared_ptr& data) const override {\n return DeviceData::Create(data);\n }\n \/\/ TODO: Scalar node is not currently used by ts_backend. Enable reusing\n \/\/ Scalar node later if needed.\n NodePtr MakeScalar(const at::Scalar& value, const at::ScalarType& type)\n const override {\n return MakeNode(value, type);\n }\n NodePtr MakeExpand(\n const Value& input0,\n const std::vector& size,\n const bool& is_scalar_expand) const override {\n return ReuseOrMakeNode(input0, size, is_scalar_expand);\n }\n NodePtr MakeView(const Value& input0, const std::vector& output_size)\n const override {\n return ReuseOrMakeNode(input0, output_size);\n }\n NodePtr MakeCast(\n const Value& input0,\n const at::ScalarType& dtype,\n const c10::optional& stype =\n c10::nullopt) const override {\n return ReuseOrMakeNode(input0, dtype, stype);\n }\n NodePtr MakeTensorList(const OpList& inputs) const override {\n return ReuseOrMakeNode(inputs);\n }\n \/\/ Generic needs cleanup\n NodePtr MakeGeneric(\n const OpKind& op,\n const OpList& operands,\n const Shape& shape,\n const size_t& num_outputs = 1,\n const hash_t& hash_seed =\n static_cast(0x5a2d296e9)) const override {\n return MakeNode(op, operands, shape, num_outputs, hash_seed);\n }\n\n \/\/ View op nodes\n NodePtr MakeAsStridedViewUpdate(\n const Value& input0,\n const Value& input1,\n const std::vector& size,\n const std::vector& stride,\n const int64_t& storage_offset) const override {\n return ReuseOrMakeNode(\n input0, input1, size, stride, storage_offset);\n }\n NodePtr MakeAsStrided(\n const Value& input0,\n const std::vector& size,\n const std::vector& stride,\n const int64_t& storage_offset) const override {\n return ReuseOrMakeNode(input0, size, stride, storage_offset);\n }\n NodePtr MakeDiagonalViewUpdate(\n const Value& input0,\n const Value& input1,\n const int64_t& offset,\n const int64_t& dim1,\n const int64_t& dim2) const override {\n return ReuseOrMakeNode(\n input0, input1, offset, dim1, dim2);\n }\n NodePtr MakeDiagonal(\n const Value& input0,\n const int64_t& offset,\n const int64_t& dim1,\n const int64_t& dim2) const override {\n return ReuseOrMakeNode(input0, offset, dim1, dim2);\n }\n NodePtr MakeNarrowViewUpdate(\n const Value& input0,\n const Value& input1,\n const std::vector& base_indices) const override {\n return ReuseOrMakeNode(input0, input1, base_indices);\n }\n NodePtr MakeNarrow(\n const Value& input0,\n const std::vector& base_indices,\n const std::vector& sizes) const override {\n return ReuseOrMakeNode(input0, base_indices, sizes);\n }\n NodePtr MakePermute(const Value& input0, const std::vector& dims)\n const override {\n return ReuseOrMakeNode(input0, dims);\n }\n NodePtr MakeResize(const Value& input0, const std::vector& size)\n const override {\n return ReuseOrMakeNode(input0, size);\n }\n NodePtr MakeSelectViewUpdate(\n const Value& input0,\n const Value& input1,\n const int64_t& dim,\n const int64_t& start,\n const int64_t& end,\n const int64_t& stride) const override {\n return ReuseOrMakeNode(\n input0, input1, dim, start, end, stride);\n }\n NodePtr MakeSelect(\n const Value& input0,\n const int64_t& dim,\n const int64_t& start,\n const int64_t& end,\n const int64_t& stride) const override {\n return ReuseOrMakeNode