content
stringlengths 6
1.05M
| obf_code
stringlengths 6
1.05M
| probability
float64 0
1
| obf_dict
stringlengths 0
25.3k
|
---|---|---|---|
/**
* \file
*
* \brief SAM Temperature Sensor (TSENS) Driver
*
* Copyright (C) 2015 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel microcontroller product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* \asf_license_stop
*
*/
/*
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/
#include "tsens.h"
#define WINDOW_MIN_VALUE -40
#define WINDOW_MAX_VALUE 105
/**
* \internal Writes an TSENS configuration to the hardware module
*
* Writes out a given TSENS module configuration to the hardware module.
*
* \param[in] config Pointer to configuration struct
*
* \return Status of the configuration procedure.
* \retval STATUS_OK The configuration was successful
* \retval STATUS_ERR_INVALID_ARG Invalid argument(s) were provided
*/
static enum status_code _tsens_set_config(struct tsens_config *const config)
{
/* Configure GCLK channel and enable clock */
struct system_gclk_chan_config gclk_chan_conf;
system_gclk_chan_get_config_defaults(&gclk_chan_conf);
gclk_chan_conf.source_generator = config->clock_source;
system_gclk_chan_set_config(TSENS_GCLK_ID, &gclk_chan_conf);
system_gclk_chan_enable(TSENS_GCLK_ID);
/* Configure run in standby */
TSENS->CTRLA.reg = (config->run_in_standby << TSENS_CTRLA_RUNSTDBY_Pos);
/* Check validity of window thresholds */
if (config->window.window_mode != TSENS_WINDOW_MODE_DISABLE) {
if((config->window.window_lower_value < WINDOW_MIN_VALUE) || \
(config->window.window_upper_value > WINDOW_MAX_VALUE)) {
return STATUS_ERR_INVALID_ARG;
}
}
/* Configure CTRLC */
TSENS->CTRLC.reg =
(config->free_running << TSENS_CTRLC_FREERUN_Pos) | \
(config->window.window_mode);
#if ERRATA_14476
/* Configure lower threshold */
TSENS->WINLT.reg = TSENS_WINLT_WINLT(config->window.window_upper_value);
/* Configure upper threshold */
TSENS->WINUT.reg = TSENS_WINLT_WINLT(config->window.window_lower_value);
#else
/* Configure lower threshold */
TSENS->WINLT.reg = TSENS_WINLT_WINLT(config->window.window_lower_value);
/* Configure upper threshold */
TSENS->WINUT.reg = TSENS_WINLT_WINLT(config->window.window_upper_value);
#endif
/* Configure events */
TSENS->EVCTRL.reg = config->event_action;
/* Disable all interrupts */
TSENS->INTENCLR.reg =
(1 << TSENS_INTENCLR_OVF_Pos) | (1 << TSENS_INTENCLR_WINMON_Pos) | \
(1 << TSENS_INTENCLR_OVERRUN_Pos) | (1 << TSENS_INTENCLR_RESRDY_Pos);
/* Read calibration from NVM */
uint32_t tsens_bits = *((uint32_t *)NVMCTRL_TEMP_LOG);
uint32_t tsens_tcal = \
((tsens_bits & TSENS_FUSES_TCAL_Msk) >> TSENS_FUSES_TCAL_Pos);
uint32_t tsens_fcal = \
((tsens_bits & TSENS_FUSES_FCAL_Msk) >> TSENS_FUSES_FCAL_Pos);
TSENS->CAL.reg = TSENS_CAL_TCAL(tsens_tcal) | TSENS_CAL_FCAL(tsens_fcal);
TSENS->GAIN.reg = TSENS_GAIN_GAIN(config->calibration.gain);
TSENS->OFFSET.reg = TSENS_OFFSET_OFFSETC(config->calibration.offset);
return STATUS_OK;
}
/**
* \brief Initializes the TSENS.
*
* Initializes the TSENS device struct and the hardware module based on the
* given configuration struct values.
*
* \param[in] config Pointer to the configuration struct
*
* \return Status of the initialization procedure.
* \retval STATUS_OK The initialization was successful
* \retval STATUS_ERR_INVALID_ARG Invalid argument(s) were provided
* \retval STATUS_BUSY The module is busy with a reset operation
* \retval STATUS_ERR_DENIED The module is enabled
*/
enum status_code tsens_init(struct tsens_config *config)
{
/* Sanity check arguments */
Assert(config);
/* Turn on the digital interface clock */
system_apb_clock_set_mask(SYSTEM_CLOCK_APB_APBA, MCLK_APBAMASK_TSENS);
if (TSENS->CTRLA.reg & TSENS_CTRLA_SWRST) {
/* We are in the middle of a reset. Abort. */
return STATUS_BUSY;
}
if (TSENS->CTRLA.reg & TSENS_CTRLA_ENABLE) {
/* Module must be disabled before initialization. Abort. */
return STATUS_ERR_DENIED;
}
/* Write configuration to module */
return _tsens_set_config(config);
}
/**
* \brief Initializes an TSENS configuration structure to defaults.
*
* Initializes a given TSENS configuration struct to a set of known default
* values. This function should be called on any new instance of the
* configuration struct before being modified by the user application.
*
* The default configuration is as follows:
* \li GCLK generator 0 (GCLK main) clock source
* \li All events (input and generation) disabled
* \li Free running disabled
* \li Run in standby disabled
* \li Window monitor disabled
* \li Register GAIN value
* \li Register OFFSET value
*
* \note Register GAIN and OFFSET is loaded from NVM, or can also be fixed.
* If this bitfield is to be fixed, pay attention to the relationship between GCLK
* frequency, GAIN, and resolution. See \ref asfdoc_sam0_tsens_module_overview
* "Chapter Module Overview".
*
* \param[out] config Pointer to configuration struct to initialize to
* default values
*/
void tsens_get_config_defaults(struct tsens_config *const config)
{
Assert(config);
config->clock_source = GCLK_GENERATOR_0;
config->free_running = false;
config->run_in_standby = false;
config->window.window_mode = TSENS_WINDOW_MODE_DISABLE;
config->window.window_upper_value = 0;
config->window.window_lower_value = 0;
config->event_action = TSENS_EVENT_ACTION_DISABLED;
uint32_t tsens_bits[2];
tsens_bits[0] = *((uint32_t *)NVMCTRL_TEMP_LOG);
tsens_bits[1] = *(((uint32_t *)NVMCTRL_TEMP_LOG) + 1);
config->calibration.offset = \
((tsens_bits[0] & TSENS_FUSES_OFFSET_Msk) >> TSENS_FUSES_OFFSET_Pos);
config->calibration.gain = \
((tsens_bits[0] & TSENS_FUSES_GAIN_0_Msk) >> TSENS_FUSES_GAIN_0_Pos) | \
((tsens_bits[1] & TSENS_FUSES_GAIN_1_Msk) >> TSENS_FUSES_GAIN_1_Pos);
}
/**
* \brief Reads the TSENS result.
*
* Reads the result from a TSENS conversion that was previously started.
*
* \param[out] result Pointer to store the result value in
*
* \return Status of the TSENS read request.
* \retval STATUS_OK The result was retrieved successfully
* \retval STATUS_BUSY A conversion result was not ready
* \retval STATUS_ERR_OVERFLOW The result register has been overwritten by the
* TSENS module before the result was read by the software
*/
enum status_code tsens_read(int32_t *result)
{
Assert(result);
if (!(tsens_get_status() & TSENS_STATUS_RESULT_READY)) {
/* Result not ready */
return STATUS_BUSY;
}
if (TSENS->STATUS.reg & TSENS_STATUS_OVF) {
/* The result is not valid */
return STATUS_ERR_BAD_DATA;
}
/* Get TSENS result */
uint32_t temp = TSENS->VALUE.reg;
if(temp & 0x00800000) {
temp |= ~TSENS_VALUE_MASK;
}
#if (ERRATA_14476)
*result = temp * (-1);
#endif
/* Reset ready flag */
tsens_clear_status(TSENS_STATUS_RESULT_READY);
if (tsens_get_status() & TSENS_STATUS_OVERRUN) {
tsens_clear_status(TSENS_STATUS_OVERRUN);
return STATUS_ERR_OVERFLOW;
}
return STATUS_OK;
}
| /**
* \file
*
* \brief SAM Temperature Sensor (TSENS) Driver
*
* Copyright (C) 2015 Atmel Corporation. All rights reserved.
*
* \asf_license_start
*
* \page License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name of Atmel may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* 4. This software may only be redistributed and used in connection with an
* Atmel microcontroller product.
*
* THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* \asf_license_stop
*
*/
/*
* Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
*/
#include "tsens.h"
#define VAR_0 -40
#define WINDOW_MAX_VALUE 105
/**
* \internal Writes an TSENS configuration to the hardware module
*
* Writes out a given TSENS module configuration to the hardware module.
*
* \param[in] config Pointer to configuration struct
*
* \return Status of the configuration procedure.
* \retval STATUS_OK The configuration was successful
* \retval STATUS_ERR_INVALID_ARG Invalid argument(s) were provided
*/
static enum status_code FUNC_0(struct tsens_config *const config)
{
/* Configure GCLK channel and enable clock */
struct CLASS_0 gclk_chan_conf;
FUNC_1(&gclk_chan_conf);
gclk_chan_conf.source_generator = config->VAR_1;
system_gclk_chan_set_config(VAR_2, &gclk_chan_conf);
system_gclk_chan_enable(VAR_2);
/* Configure run in standby */
VAR_3->VAR_4.VAR_5 = (config->run_in_standby << VAR_6);
/* Check validity of window thresholds */
if (config->VAR_7.VAR_8 != TSENS_WINDOW_MODE_DISABLE) {
if((config->VAR_7.window_lower_value < VAR_0) || \
(config->VAR_7.window_upper_value > WINDOW_MAX_VALUE)) {
return VAR_9;
}
}
/* Configure CTRLC */
VAR_3->VAR_10.VAR_5 =
(config->VAR_11 << VAR_12) | \
(config->VAR_7.VAR_8);
#if ERRATA_14476
/* Configure lower threshold */
VAR_3->VAR_13.VAR_5 = FUNC_2(config->VAR_7.window_upper_value);
/* Configure upper threshold */
VAR_3->WINUT.VAR_5 = FUNC_2(config->VAR_7.window_lower_value);
#else
/* Configure lower threshold */
VAR_3->VAR_13.VAR_5 = FUNC_2(config->VAR_7.window_lower_value);
/* Configure upper threshold */
VAR_3->WINUT.VAR_5 = FUNC_2(config->VAR_7.window_upper_value);
#endif
/* Configure events */
VAR_3->EVCTRL.VAR_5 = config->VAR_14;
/* Disable all interrupts */
VAR_3->INTENCLR.VAR_5 =
(1 << VAR_15) | (1 << VAR_16) | \
(1 << TSENS_INTENCLR_OVERRUN_Pos) | (1 << VAR_17);
/* Read calibration from NVM */
uint32_t tsens_bits = *((uint32_t *)NVMCTRL_TEMP_LOG);
uint32_t tsens_tcal = \
((tsens_bits & TSENS_FUSES_TCAL_Msk) >> VAR_18);
uint32_t tsens_fcal = \
((tsens_bits & VAR_19) >> TSENS_FUSES_FCAL_Pos);
VAR_3->VAR_20.VAR_5 = TSENS_CAL_TCAL(tsens_tcal) | TSENS_CAL_FCAL(tsens_fcal);
VAR_3->GAIN.VAR_5 = FUNC_3(config->VAR_21.gain);
VAR_3->OFFSET.VAR_5 = FUNC_4(config->VAR_21.VAR_22);
return VAR_23;
}
/**
* \brief Initializes the TSENS.
*
* Initializes the TSENS device struct and the hardware module based on the
* given configuration struct values.
*
* \param[in] config Pointer to the configuration struct
*
* \return Status of the initialization procedure.
* \retval STATUS_OK The initialization was successful
* \retval STATUS_ERR_INVALID_ARG Invalid argument(s) were provided
* \retval STATUS_BUSY The module is busy with a reset operation
* \retval STATUS_ERR_DENIED The module is enabled
*/
enum status_code tsens_init(struct tsens_config *config)
{
/* Sanity check arguments */
Assert(config);
/* Turn on the digital interface clock */
FUNC_5(VAR_24, MCLK_APBAMASK_TSENS);
if (VAR_3->VAR_4.VAR_5 & VAR_25) {
/* We are in the middle of a reset. Abort. */
return VAR_26;
}
if (VAR_3->VAR_4.VAR_5 & TSENS_CTRLA_ENABLE) {
/* Module must be disabled before initialization. Abort. */
return STATUS_ERR_DENIED;
}
/* Write configuration to module */
return FUNC_0(config);
}
/**
* \brief Initializes an TSENS configuration structure to defaults.
*
* Initializes a given TSENS configuration struct to a set of known default
* values. This function should be called on any new instance of the
* configuration struct before being modified by the user application.
*
* The default configuration is as follows:
* \li GCLK generator 0 (GCLK main) clock source
* \li All events (input and generation) disabled
* \li Free running disabled
* \li Run in standby disabled
* \li Window monitor disabled
* \li Register GAIN value
* \li Register OFFSET value
*
* \note Register GAIN and OFFSET is loaded from NVM, or can also be fixed.
* If this bitfield is to be fixed, pay attention to the relationship between GCLK
* frequency, GAIN, and resolution. See \ref asfdoc_sam0_tsens_module_overview
* "Chapter Module Overview".
*
* \param[out] config Pointer to configuration struct to initialize to
* default values
*/
void FUNC_6(struct tsens_config *const config)
{
Assert(config);
config->VAR_1 = VAR_27;
config->VAR_11 = false;
config->run_in_standby = false;
config->VAR_7.VAR_8 = TSENS_WINDOW_MODE_DISABLE;
config->VAR_7.window_upper_value = 0;
config->VAR_7.window_lower_value = 0;
config->VAR_14 = VAR_28;
uint32_t tsens_bits[2];
tsens_bits[0] = *((uint32_t *)NVMCTRL_TEMP_LOG);
tsens_bits[1] = *(((uint32_t *)NVMCTRL_TEMP_LOG) + 1);
config->VAR_21.VAR_22 = \
((tsens_bits[0] & TSENS_FUSES_OFFSET_Msk) >> VAR_29);
config->VAR_21.gain = \
((tsens_bits[0] & VAR_30) >> VAR_31) | \
((tsens_bits[1] & VAR_32) >> TSENS_FUSES_GAIN_1_Pos);
}
/**
* \brief Reads the TSENS result.
*
* Reads the result from a TSENS conversion that was previously started.
*
* \param[out] result Pointer to store the result value in
*
* \return Status of the TSENS read request.
* \retval STATUS_OK The result was retrieved successfully
* \retval STATUS_BUSY A conversion result was not ready
* \retval STATUS_ERR_OVERFLOW The result register has been overwritten by the
* TSENS module before the result was read by the software
*/
enum status_code FUNC_7(int32_t *result)
{
Assert(result);
if (!(tsens_get_status() & TSENS_STATUS_RESULT_READY)) {
/* Result not ready */
return VAR_26;
}
if (VAR_3->VAR_33.VAR_5 & VAR_34) {
/* The result is not valid */
return STATUS_ERR_BAD_DATA;
}
/* Get TSENS result */
uint32_t VAR_35 = VAR_3->VALUE.VAR_5;
if(VAR_35 & 0x00800000) {
VAR_35 |= ~TSENS_VALUE_MASK;
}
#if (ERRATA_14476)
*result = VAR_35 * (-1);
#endif
/* Reset ready flag */
tsens_clear_status(TSENS_STATUS_RESULT_READY);
if (tsens_get_status() & VAR_36) {
tsens_clear_status(VAR_36);
return VAR_37;
}
return VAR_23;
}
| 0.553354 | {'VAR_0': 'WINDOW_MIN_VALUE', 'FUNC_0': '_tsens_set_config', 'CLASS_0': 'system_gclk_chan_config', 'FUNC_1': 'system_gclk_chan_get_config_defaults', 'VAR_1': 'clock_source', 'VAR_2': 'TSENS_GCLK_ID', 'VAR_3': 'TSENS', 'VAR_4': 'CTRLA', 'VAR_5': 'reg', 'VAR_6': 'TSENS_CTRLA_RUNSTDBY_Pos', 'VAR_7': 'window', 'VAR_8': 'window_mode', 'VAR_9': 'STATUS_ERR_INVALID_ARG', 'VAR_10': 'CTRLC', 'VAR_11': 'free_running', 'VAR_12': 'TSENS_CTRLC_FREERUN_Pos', 'VAR_13': 'WINLT', 'FUNC_2': 'TSENS_WINLT_WINLT', 'VAR_14': 'event_action', 'VAR_15': 'TSENS_INTENCLR_OVF_Pos', 'VAR_16': 'TSENS_INTENCLR_WINMON_Pos', 'VAR_17': 'TSENS_INTENCLR_RESRDY_Pos', 'VAR_18': 'TSENS_FUSES_TCAL_Pos', 'VAR_19': 'TSENS_FUSES_FCAL_Msk', 'VAR_20': 'CAL', 'FUNC_3': 'TSENS_GAIN_GAIN', 'VAR_21': 'calibration', 'FUNC_4': 'TSENS_OFFSET_OFFSETC', 'VAR_22': 'offset', 'VAR_23': 'STATUS_OK', 'FUNC_5': 'system_apb_clock_set_mask', 'VAR_24': 'SYSTEM_CLOCK_APB_APBA', 'VAR_25': 'TSENS_CTRLA_SWRST', 'VAR_26': 'STATUS_BUSY', 'FUNC_6': 'tsens_get_config_defaults', 'VAR_27': 'GCLK_GENERATOR_0', 'VAR_28': 'TSENS_EVENT_ACTION_DISABLED', 'VAR_29': 'TSENS_FUSES_OFFSET_Pos', 'VAR_30': 'TSENS_FUSES_GAIN_0_Msk', 'VAR_31': 'TSENS_FUSES_GAIN_0_Pos', 'VAR_32': 'TSENS_FUSES_GAIN_1_Msk', 'FUNC_7': 'tsens_read', 'VAR_33': 'STATUS', 'VAR_34': 'TSENS_STATUS_OVF', 'VAR_35': 'temp', 'VAR_36': 'TSENS_STATUS_OVERRUN', 'VAR_37': 'STATUS_ERR_OVERFLOW'} |
//
// Created by Dado on 01/01/2018.
//
#pragma once
void mainLoop( const CLIParamMap& params, std::unique_ptr<RunLoopBackEndBase>&& _be );
| //
// Created by Dado on 01/01/2018.
//
#pragma once
void FUNC_0( const CLASS_0& VAR_0, CLASS_1::VAR_1<VAR_2>&& VAR_3 );
| 0.719202 | {'FUNC_0': 'mainLoop', 'CLASS_0': 'CLIParamMap', 'VAR_0': 'params', 'CLASS_1': 'std', 'VAR_1': 'unique_ptr', 'VAR_2': 'RunLoopBackEndBase', 'VAR_3': '_be'} |
#include "uart.h"
int main(int argc, char **argv)
{
int fd;
int baud;
char dev_name[128];
printf("Serial Test Start... (%s)\n", __DATE__);
strcpy(dev_name, "/dev/ttyACM0");
baud = 115200;
fd = open_serial(dev_name, baud, 10, 32);
if(fd < 0)
return -2;
gsm_msg_send(fd, "01029807183", "Hello BitAI");
close_serial(fd);
printf("Message Send Success\n");
return 0;
}
| #include "IMPORT_0"
int FUNC_0(int VAR_0, char **VAR_1)
{
int VAR_2;
int baud;
char VAR_3[128];
printf("Serial Test Start... (%s)\n", VAR_4);
strcpy(VAR_3, "/dev/ttyACM0");
baud = 115200;
VAR_2 = FUNC_1(VAR_3, baud, 10, 32);
if(VAR_2 < 0)
return -2;
FUNC_2(VAR_2, "01029807183", "Hello BitAI");
FUNC_3(VAR_2);
printf("Message Send Success\n");
return 0;
}
| 0.717216 | {'IMPORT_0': 'uart.h', 'FUNC_0': 'main', 'VAR_0': 'argc', 'VAR_1': 'argv', 'VAR_2': 'fd', 'VAR_3': 'dev_name', 'VAR_4': '__DATE__', 'FUNC_1': 'open_serial', 'FUNC_2': 'gsm_msg_send', 'FUNC_3': 'close_serial'} |
#include <stdio.h>
int main ()
{
int counter;
int a = -1;
printf("--- Contador Regressivo ---\n");
printf("Em que numero pretende começar? ");
scanf("%i", &counter);
while (a < counter)
{
printf("%i\n", counter);
counter--;
}
} | #include <stdio.h>
int main ()
{
int counter;
int a = -1;
printf("--- Contador Regressivo ---\n");
printf("Em que numero pretende começar? ");
scanf("%i", &counter);
while (a < counter)
{
printf("%i\n", counter);
counter--;
}
} | 0.201941 | {} |
#include<stdio.h>
main()
{
int a[3][3],b[3][3],c[3][3],i,j,k,sum;
printf("Enter 9 number for first matrix\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
scanf("%d",&a[i][j]);
}
printf("Enter 9 number for second matrix\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
scanf("%d",&b[i][j]);
}
printf("multiplication of matrix\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
sum=0;
for(k=0;k<=2;k++)
sum=sum+a[i][k]*b[k][j];
c[i][j]=sum;
}
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
printf("%d ",c[i][j]);
printf("\n");
}
printf("\n");
}
| #include<stdio.h>
FUNC_0()
{
int VAR_0[3][3],b[3][3],VAR_1[3][3],i,j,k,VAR_2;
printf("Enter 9 number for first matrix\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
scanf("%d",&VAR_0[i][j]);
}
printf("Enter 9 number for second matrix\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
scanf("%d",&b[i][j]);
}
printf("multiplication of matrix\n");
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
VAR_2=0;
for(k=0;k<=2;k++)
VAR_2=VAR_2+VAR_0[i][k]*b[k][j];
VAR_1[i][j]=VAR_2;
}
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
printf("%d ",VAR_1[i][j]);
printf("\n");
}
printf("\n");
}
| 0.506353 | {'FUNC_0': 'main', 'VAR_0': 'a', 'VAR_1': 'c', 'VAR_2': 'sum'} |
//
// match.c
// machodiff
//
// Created by <NAME> on 3/19/14.
// Copyright (c) 2014 <NAME>. All rights reserved.
//
#ifndef machodiff_match_c
#define machodiff_match_c
#include "match.h"
struct loader_match_tree * SDMBuildMatchTree(CoreRange buffer1, CoreRange buffer2) {
struct loader_match_tree *root = calloc(1, sizeof(struct loader_match_tree));
root->parent = NULL;
struct loader_match_tree *current_node = root;
uint64_t counter = 1;
bool match_result = false;
uint64_t lesser_length = (buffer1.length < buffer2.length ? buffer1.length : buffer2.length);
uint64_t compare_length = 0;
uint8_t *offset1 = PtrCast(Ptr(buffer1.offset), uint8_t *);
uint8_t *offset2 = PtrCast(Ptr(buffer2.offset), uint8_t *);
while (compare_length < lesser_length) {
match_result = (memcmp(offset1, offset2, sizeof(char[counter])) == 0);
if (match_result) {
counter++;
compare_length++;
}
else {
if (counter > 1) {
// SDM: break in chain
current_node->matched1 = CoreRangeCreate((uint64_t)offset1, counter);
current_node->matched2 = CoreRangeCreate((uint64_t)offset2, counter);
struct loader_match_tree *child = calloc(1, sizeof(struct loader_match_tree));
child->parent = current_node;
current_node->child = child;
current_node = child;
}
else {
compare_length++;
}
offset1 = (uint8_t*)PtrAdd(offset1, counter);
offset2 = (uint8_t*)PtrAdd(offset2, counter);
counter = 1;
}
}
return root;
}
uint8_t SDMMatchPercentFromTree(struct loader_match_tree *tree, uint64_t total_length) {
uint64_t matched_length = SDMMatchLengthFromTree(tree);
double matched = (double)matched_length;
double total = (double)total_length;
uint8_t result = (uint8_t)round((matched/total)*100);
return result;
}
uint64_t SDMMatchLengthFromTree(struct loader_match_tree *tree) {
uint64_t matched_length = 0;
if (tree) {
struct loader_match_tree *node = tree->child;
if (node) {
matched_length += SDMMatchLengthFromTree(node);
}
matched_length += tree->matched1.length;
}
return matched_length;
}
void SDMReleaseMatchTree(struct loader_match_tree *tree) {
if (tree) {
struct loader_match_tree *node = tree->child;
if (node) {
SDMReleaseMatchTree(node);
}
free(tree);
}
}
#endif
| //
// match.c
// machodiff
//
// Created by <NAME> on 3/19/14.
// Copyright (c) 2014 <NAME>. All rights reserved.
//
#ifndef machodiff_match_c
#define machodiff_match_c
#include "IMPORT_0"
struct CLASS_0 * SDMBuildMatchTree(CLASS_1 VAR_0, CLASS_1 buffer2) {
struct CLASS_0 *VAR_1 = FUNC_0(1, sizeof(struct CLASS_0));
VAR_1->VAR_2 = NULL;
struct CLASS_0 *VAR_3 = VAR_1;
uint64_t VAR_4 = 1;
bool match_result = false;
uint64_t lesser_length = (VAR_0.VAR_5 < buffer2.VAR_5 ? VAR_0.VAR_5 : buffer2.VAR_5);
uint64_t VAR_6 = 0;
uint8_t *VAR_7 = PtrCast(FUNC_1(VAR_0.offset), uint8_t *);
uint8_t *VAR_8 = PtrCast(FUNC_1(buffer2.offset), uint8_t *);
while (VAR_6 < lesser_length) {
match_result = (FUNC_2(VAR_7, VAR_8, sizeof(char[VAR_4])) == 0);
if (match_result) {
VAR_4++;
VAR_6++;
}
else {
if (VAR_4 > 1) {
// SDM: break in chain
VAR_3->VAR_9 = CoreRangeCreate((uint64_t)VAR_7, VAR_4);
VAR_3->VAR_10 = CoreRangeCreate((uint64_t)VAR_8, VAR_4);
struct CLASS_0 *VAR_11 = FUNC_0(1, sizeof(struct CLASS_0));
VAR_11->VAR_2 = VAR_3;
VAR_3->VAR_11 = VAR_11;
VAR_3 = VAR_11;
}
else {
VAR_6++;
}
VAR_7 = (uint8_t*)PtrAdd(VAR_7, VAR_4);
VAR_8 = (uint8_t*)PtrAdd(VAR_8, VAR_4);
VAR_4 = 1;
}
}
return VAR_1;
}
uint8_t SDMMatchPercentFromTree(struct CLASS_0 *tree, uint64_t VAR_12) {
uint64_t VAR_13 = SDMMatchLengthFromTree(tree);
double VAR_14 = (double)VAR_13;
double VAR_15 = (double)VAR_12;
uint8_t result = (uint8_t)round((VAR_14/VAR_15)*100);
return result;
}
uint64_t SDMMatchLengthFromTree(struct CLASS_0 *tree) {
uint64_t VAR_13 = 0;
if (tree) {
struct CLASS_0 *VAR_16 = tree->VAR_11;
if (VAR_16) {
VAR_13 += SDMMatchLengthFromTree(VAR_16);
}
VAR_13 += tree->VAR_9.VAR_5;
}
return VAR_13;
}
void SDMReleaseMatchTree(struct CLASS_0 *tree) {
if (tree) {
struct CLASS_0 *VAR_16 = tree->VAR_11;
if (VAR_16) {
SDMReleaseMatchTree(VAR_16);
}
FUNC_3(tree);
}
}
#endif
| 0.442198 | {'IMPORT_0': 'match.h', 'CLASS_0': 'loader_match_tree', 'CLASS_1': 'CoreRange', 'VAR_0': 'buffer1', 'VAR_1': 'root', 'FUNC_0': 'calloc', 'VAR_2': 'parent', 'VAR_3': 'current_node', 'VAR_4': 'counter', 'VAR_5': 'length', 'VAR_6': 'compare_length', 'VAR_7': 'offset1', 'FUNC_1': 'Ptr', 'VAR_8': 'offset2', 'FUNC_2': 'memcmp', 'VAR_9': 'matched1', 'VAR_10': 'matched2', 'VAR_11': 'child', 'VAR_12': 'total_length', 'VAR_13': 'matched_length', 'VAR_14': 'matched', 'VAR_15': 'total', 'VAR_16': 'node', 'FUNC_3': 'free'} |
#ifndef _PPS_H_
#define _PPS_H_
/* ************************************************************************** */
/* Notes on using the PPS (Peripheral Pin Select)
The PIC18 K42 family microcontrollers has a Peripheral Pin Select module
that allows the remapping of digital I/O pins.
*/
/* ************************************************************************** */
/* Notes on managing the PPS Lock
These macros are designed to help each software module manage its own PPS
settings. Writes to PPS registers while the system is locked are ignored.
Each software module is responsible for putting its required PPS setup code
in it's module_init(). If all the various module_init() calls are collected
into one place, like startup(), then the block of _init() calls can be
wrapped with these two macros, and the entire system's PPS requirements can
be satisfied in one shot.
*/
extern void pps_unlock(void);
extern void pps_lock(void);
/* ************************************************************************** */
/* PPS Input Registers
Example PPS Input assignments:
Connecting the Timer 3 Clock input to pin RB0:
pps_in_TIMER3_CLOCK(PPS_IN(B, 0));
Connecting the UART 1 Recieve input to pin RC7:
pps_in_UART1_RX(PPS_IN(C, 7));
Connecting the ADC Trigger input to RA4, through a function call:
void some_init(pps_input_t pin){
pps_in_ADC_TRIGGER(pin);
}
void some_other_function(void) {
some_init(PPS_IN(A, 4));
}
*/
// Can be used to pass PPS pins into a function
typedef unsigned char pps_input_t;
// macro to help abbreviate
#define PPS_INPUT(port, pin) (PPS_PORT_##port & PPS_PIN_##pin)
/* -------------------------------------------------------------------------- */
// Input pin assignment macros
#define PPS_PORT_A 0b11000111
#define PPS_PORT_B 0b11001111
#define PPS_PORT_C 0b11010111
#define PPS_PORT_D 0b11011111
#define PPS_PORT_E 0b11100111
#define PPS_PORT_F 0b11101111
#define PPS_PIN_0 0b11111000
#define PPS_PIN_1 0b11111001
#define PPS_PIN_2 0b11111010
#define PPS_PIN_3 0b11111011
#define PPS_PIN_4 0b11111100
#define PPS_PIN_5 0b11111101
#define PPS_PIN_6 0b11111110
#define PPS_PIN_7 0b11111111
/* -------------------------------------------------------------------------- */
extern void pps_in_INTERRUPT0(pps_input_t pin);
extern void pps_in_INTERRUPT1(pps_input_t pin);
extern void pps_in_INTERRUPT2(pps_input_t pin);
/* -------------------------------------------------------------------------- */
extern void pps_in_TIMER0_CLOCK(pps_input_t pin);
extern void pps_in_TIMER1_CLOCK(pps_input_t pin);
extern void pps_in_TIMER1_GATE(pps_input_t pin);
extern void pps_in_TIMER3_CLOCK(pps_input_t pin);
extern void pps_in_TIMER3_GATE(pps_input_t pin);
extern void pps_in_TIMER5_CLOCK(pps_input_t pin);
extern void pps_in_TIMER5_GATE(pps_input_t pin);
extern void pps_in_TIMER2_CLOCK(pps_input_t pin);
extern void pps_in_TIMER4_CLOCK(pps_input_t pin);
extern void pps_in_TIMER6_CLOCK(pps_input_t pin);
/* -------------------------------------------------------------------------- */
extern void pps_in_CCP1(pps_input_t pin);
extern void pps_in_CCP2(pps_input_t pin);
extern void pps_in_CCP3(pps_input_t pin);
extern void pps_in_CCP4(pps_input_t pin); //* K42 only
/* -------------------------------------------------------------------------- */
extern void pps_in_PWM_Input_0(pps_input_t pin); //* Q43 only
extern void pps_in_PWM_Input_1(pps_input_t pin); //* Q43 only
extern void pps_in_PWM1_External_Reset(pps_input_t pin); //* Q43 only
extern void pps_in_PWM2_External_Reset(pps_input_t pin); //* Q43 only
extern void pps_in_PWM3_External_Reset(pps_input_t pin); //* Q43 only
/* -------------------------------------------------------------------------- */
extern void pps_in_SMT1_WINDOW(pps_input_t pin);
extern void pps_in_SMT1_SIGNAL(pps_input_t pin);
/* -------------------------------------------------------------------------- */
extern void pps_in_CWG1(pps_input_t pin); //* Q43 only (by mistake)
extern void pps_in_CWG2(pps_input_t pin); //* Q43 only (by mistake)
extern void pps_in_CWG3(pps_input_t pin); //* Q43 only (by mistake)
/* -------------------------------------------------------------------------- */
extern void pps_in_DSM_CARRIER_LOW(pps_input_t pin);
extern void pps_in_DSM_CARRIER_HIGH(pps_input_t pin);
extern void pps_in_DSM_SOURCE(pps_input_t pin);
/* -------------------------------------------------------------------------- */
extern void pps_in_CLC1_INPUT(pps_input_t pin);
extern void pps_in_CLC2_INPUT(pps_input_t pin);
extern void pps_in_CLC3_INPUT(pps_input_t pin);
extern void pps_in_CLC4_INPUT(pps_input_t pin);
extern void pps_in_CLC5_INPUT(pps_input_t pin); //* Q43 only
extern void pps_in_CLC6_INPUT(pps_input_t pin); //* Q43 only
extern void pps_in_CLC7_INPUT(pps_input_t pin); //* Q43 only
extern void pps_in_CLC8_INPUT(pps_input_t pin); //* Q43 only
/* -------------------------------------------------------------------------- */
extern void pps_in_ADC_TRIGGER(pps_input_t pin);
/* -------------------------------------------------------------------------- */
extern void pps_in_SPI1_CLOCK(pps_input_t pin);
extern void pps_in_SPI1_DATA_IN(pps_input_t pin);
extern void pps_in_SPI1_SS(pps_input_t pin);
extern void pps_in_SPI2_CLOCK(pps_input_t pin); //* Q43 only
extern void pps_in_SPI2_DATA_IN(pps_input_t pin); //* Q43 only
extern void pps_in_SPI2_SS(pps_input_t pin); //* Q43 only
/* -------------------------------------------------------------------------- */
extern void pps_in_I2C1_CLOCK(pps_input_t pin);
extern void pps_in_I2C1_DATA(pps_input_t pin);
extern void pps_in_I2C2_CLOCK(pps_input_t pin); //* K42 only
extern void pps_in_I2C2_DATA(pps_input_t pin); //* K42 only
/* -------------------------------------------------------------------------- */
extern void pps_in_UART1_RX(pps_input_t pin);
extern void pps_in_UART1_CTS(pps_input_t pin);
extern void pps_in_UART2_RX(pps_input_t pin);
extern void pps_in_UART2_CTS(pps_input_t pin);
extern void pps_in_UART3_RX(pps_input_t pin); //* Q43 only
extern void pps_in_UART3_CTS(pps_input_t pin); //* Q43 only
extern void pps_in_UART4_RX(pps_input_t pin); //* Q43 only
extern void pps_in_UART4_CTS(pps_input_t pin); //* Q43 only
extern void pps_in_UART5_RX(pps_input_t pin); //* Q43 only
extern void pps_in_UART5_CTS(pps_input_t pin); //* Q43 only
/* ************************************************************************** */
/* PPS Output Registers
Example PPS Output assignments:
Assigning UART1 TX to pin RC6:
pps_out_UART1_TX(RC6PPS)
Assigning the output of PWM5 to RB2, through a function call:
void some_init(pps_output_t* outputPin){
pps_out_PWM5(outputPin);
}
void some_other_function(void) {
some_init(PPS_OUT(B, 2));
}
*/
// Can be used to pass PPS pins into a function
typedef volatile unsigned char pps_output_t;
//
#define PPS_OUTPUT(port, pin) (&R##port##pin##PPS)
/* -------------------------------------------------------------------------- */
// ADC Guard Ring Outputs
extern void pps_out_ADC_GUARD_RING_B(pps_output_t *pin);
extern void pps_out_ADC_GUARD_RING_A(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// Complementary Waveform Generator 3
extern void pps_out_CWG3D(pps_output_t *pin);
extern void pps_out_CWG3C(pps_output_t *pin);
extern void pps_out_CWG3B(pps_output_t *pin);
extern void pps_out_CWG3A(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// Complementary Waveform Generator 3
extern void pps_out_CWG2D(pps_output_t *pin);
extern void pps_out_CWG2C(pps_output_t *pin);
extern void pps_out_CWG2B(pps_output_t *pin);
extern void pps_out_CWG2A(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// Complementary Waveform Generator 3
extern void pps_out_CWG1D(pps_output_t *pin);
extern void pps_out_CWG1C(pps_output_t *pin);
extern void pps_out_CWG1B(pps_output_t *pin);
extern void pps_out_CWG1A(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// Digital Signal Modulater
extern void pps_out_DSM1(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// Reference Clock Output
extern void pps_out_CLKR(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// Numerically Controller Oscillator
extern void pps_out_NCO3(pps_output_t *pin); //* Q43 only
extern void pps_out_NCO2(pps_output_t *pin); //* Q43 only
extern void pps_out_NCO1(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// Timer 0 Output
extern void pps_out_TIMER0(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// I2C
extern void pps_out_I2C1_DATA(pps_output_t *pin);
extern void pps_out_I2C1_CLOCK(pps_output_t *pin);
extern void pps_out_I2C2_DATA(pps_output_t *pin); //* K42 only
extern void pps_out_I2C2_CLOCK(pps_output_t *pin); //* K42 only
/* -------------------------------------------------------------------------- */
// SPI
extern void pps_out_SPI1_SS(pps_output_t *pin);
extern void pps_out_SPI1_DATA_OUT(pps_output_t *pin);
extern void pps_out_SPI1_CLOCK(pps_output_t *pin);
extern void pps_out_SPI2_SS(pps_output_t *pin); //* Q43 only
extern void pps_out_SPI2_DATA_OUT(pps_output_t *pin); //* Q43 only
extern void pps_out_SPI2_CLOCK(pps_output_t *pin); //* Q43 only
/* -------------------------------------------------------------------------- */
// Comparator
extern void pps_out_COMPARATOR_2(pps_output_t *pin);
extern void pps_out_COMPARATOR_1(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// UART 5
extern void pps_out_UART5_RTS(pps_output_t *pin); //* Q43 only
extern void pps_out_UART5_TXDE(pps_output_t *pin); //* Q43 only
extern void pps_out_UART5_TX(pps_output_t *pin); //* Q43 only
/* -------------------------------------------------------------------------- */
// UART 4
extern void pps_out_UART4_RTS(pps_output_t *pin); //* Q43 only
extern void pps_out_UART4_TXDE(pps_output_t *pin); //* Q43 only
extern void pps_out_UART4_TX(pps_output_t *pin); //* Q43 only
/* -------------------------------------------------------------------------- */
// UART 3
extern void pps_out_UART3_RTS(pps_output_t *pin); //* Q43 only
extern void pps_out_UART3_TXDE(pps_output_t *pin); //* Q43 only
extern void pps_out_UART3_TX(pps_output_t *pin); //* Q43 only
/* -------------------------------------------------------------------------- */
// UART 2
extern void pps_out_UART2_RTS(pps_output_t *pin);
extern void pps_out_UART2_TXDE(pps_output_t *pin);
extern void pps_out_UART2_TX(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// UART 1
extern void pps_out_UART1_RTS(pps_output_t *pin);
extern void pps_out_UART1_TXDE(pps_output_t *pin);
extern void pps_out_UART1_TX(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// PWM
extern void pps_out_PWM8(pps_output_t *pin); //* K42 only
extern void pps_out_PWM7(pps_output_t *pin); //* K42 only
extern void pps_out_PWM6(pps_output_t *pin); //* K42 only
extern void pps_out_PWM5(pps_output_t *pin); //* K42 only
extern void pps_out_PWM3S1P2(pps_output_t *pin); //* Q43 only
extern void pps_out_PWM3S1P1(pps_output_t *pin); //* Q43 only
extern void pps_out_PWM2S1P2(pps_output_t *pin); //* Q43 only
extern void pps_out_PWM2S1P1(pps_output_t *pin); //* Q43 only
extern void pps_out_PWM1S1P2(pps_output_t *pin); //* Q43 only
extern void pps_out_PWM1S1P1(pps_output_t *pin); //* Q43 only
/* -------------------------------------------------------------------------- */
// Capture/Compare
extern void pps_out_CCP4(pps_output_t *pin); //* K42 only
extern void pps_out_CCP3(pps_output_t *pin);
extern void pps_out_CCP2(pps_output_t *pin);
extern void pps_out_CCP1(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// Configurable Logic Cell
extern void pps_out_CLC8_OUTPUT(pps_output_t *pin); //* Q43 only
extern void pps_out_CLC7_OUTPUT(pps_output_t *pin); //* Q43 only
extern void pps_out_CLC6_OUTPUT(pps_output_t *pin); //* Q43 only
extern void pps_out_CLC5_OUTPUT(pps_output_t *pin); //* Q43 only
extern void pps_out_CLC4_OUTPUT(pps_output_t *pin);
extern void pps_out_CLC3_OUTPUT(pps_output_t *pin);
extern void pps_out_CLC2_OUTPUT(pps_output_t *pin);
extern void pps_out_CLC1_OUTPUT(pps_output_t *pin);
/* -------------------------------------------------------------------------- */
// Default value of all RXYPPS registers at RESET
// Primarily used to revert a PPS configuration
extern void pps_out_LATCH(pps_output_t *pin);
/* ************************************************************************** */
#endif /* _PPS_H_ */ | #ifndef _PPS_H_
#define _PPS_H_
/* ************************************************************************** */
/* Notes on using the PPS (Peripheral Pin Select)
The PIC18 K42 family microcontrollers has a Peripheral Pin Select module
that allows the remapping of digital I/O pins.
*/
/* ************************************************************************** */
/* Notes on managing the PPS Lock
These macros are designed to help each software module manage its own PPS
settings. Writes to PPS registers while the system is locked are ignored.
Each software module is responsible for putting its required PPS setup code
in it's module_init(). If all the various module_init() calls are collected
into one place, like startup(), then the block of _init() calls can be
wrapped with these two macros, and the entire system's PPS requirements can
be satisfied in one shot.
*/
extern void FUNC_0(void);
extern void pps_lock(void);
/* ************************************************************************** */
/* PPS Input Registers
Example PPS Input assignments:
Connecting the Timer 3 Clock input to pin RB0:
pps_in_TIMER3_CLOCK(PPS_IN(B, 0));
Connecting the UART 1 Recieve input to pin RC7:
pps_in_UART1_RX(PPS_IN(C, 7));
Connecting the ADC Trigger input to RA4, through a function call:
void some_init(pps_input_t pin){
pps_in_ADC_TRIGGER(pin);
}
void some_other_function(void) {
some_init(PPS_IN(A, 4));
}
*/
// Can be used to pass PPS pins into a function
typedef unsigned char pps_input_t;
// macro to help abbreviate
#define PPS_INPUT(port, VAR_0) (PPS_PORT_##port & PPS_PIN_##pin)
/* -------------------------------------------------------------------------- */
// Input pin assignment macros
#define PPS_PORT_A 0b11000111
#define VAR_1 0b11001111
#define VAR_2 0b11010111
#define PPS_PORT_D 0b11011111
#define VAR_3 0b11100111
#define PPS_PORT_F 0b11101111
#define PPS_PIN_0 0b11111000
#define PPS_PIN_1 0b11111001
#define VAR_4 0b11111010
#define PPS_PIN_3 0b11111011
#define PPS_PIN_4 0b11111100
#define PPS_PIN_5 0b11111101
#define VAR_5 0b11111110
#define VAR_6 0b11111111
/* -------------------------------------------------------------------------- */
extern void pps_in_INTERRUPT0(pps_input_t VAR_0);
extern void FUNC_1(pps_input_t VAR_0);
extern void FUNC_2(pps_input_t VAR_0);
/* -------------------------------------------------------------------------- */
extern void pps_in_TIMER0_CLOCK(pps_input_t VAR_0);
extern void pps_in_TIMER1_CLOCK(pps_input_t VAR_0);
extern void FUNC_3(pps_input_t VAR_0);
extern void pps_in_TIMER3_CLOCK(pps_input_t VAR_0);
extern void pps_in_TIMER3_GATE(pps_input_t VAR_0);
extern void pps_in_TIMER5_CLOCK(pps_input_t VAR_0);
extern void pps_in_TIMER5_GATE(pps_input_t VAR_0);
extern void pps_in_TIMER2_CLOCK(pps_input_t VAR_0);
extern void pps_in_TIMER4_CLOCK(pps_input_t VAR_0);
extern void pps_in_TIMER6_CLOCK(pps_input_t VAR_0);
/* -------------------------------------------------------------------------- */
extern void pps_in_CCP1(pps_input_t VAR_0);
extern void FUNC_4(pps_input_t VAR_0);
extern void FUNC_5(pps_input_t VAR_0);
extern void pps_in_CCP4(pps_input_t VAR_0); //* K42 only
/* -------------------------------------------------------------------------- */
extern void pps_in_PWM_Input_0(pps_input_t VAR_0); //* Q43 only
extern void FUNC_6(pps_input_t VAR_0); //* Q43 only
extern void pps_in_PWM1_External_Reset(pps_input_t VAR_0); //* Q43 only
extern void pps_in_PWM2_External_Reset(pps_input_t VAR_0); //* Q43 only
extern void pps_in_PWM3_External_Reset(pps_input_t VAR_0); //* Q43 only
/* -------------------------------------------------------------------------- */
extern void FUNC_7(pps_input_t VAR_0);
extern void FUNC_8(pps_input_t VAR_0);
/* -------------------------------------------------------------------------- */
extern void pps_in_CWG1(pps_input_t VAR_0); //* Q43 only (by mistake)
extern void FUNC_9(pps_input_t VAR_0); //* Q43 only (by mistake)
extern void pps_in_CWG3(pps_input_t VAR_0); //* Q43 only (by mistake)
/* -------------------------------------------------------------------------- */
extern void FUNC_10(pps_input_t VAR_0);
extern void FUNC_11(pps_input_t VAR_0);
extern void FUNC_12(pps_input_t VAR_0);
/* -------------------------------------------------------------------------- */
extern void pps_in_CLC1_INPUT(pps_input_t VAR_0);
extern void FUNC_13(pps_input_t VAR_0);
extern void pps_in_CLC3_INPUT(pps_input_t VAR_0);
extern void FUNC_14(pps_input_t VAR_0);
extern void pps_in_CLC5_INPUT(pps_input_t VAR_0); //* Q43 only
extern void pps_in_CLC6_INPUT(pps_input_t VAR_0); //* Q43 only
extern void pps_in_CLC7_INPUT(pps_input_t VAR_0); //* Q43 only
extern void pps_in_CLC8_INPUT(pps_input_t VAR_0); //* Q43 only
/* -------------------------------------------------------------------------- */
extern void FUNC_15(pps_input_t VAR_0);
/* -------------------------------------------------------------------------- */
extern void pps_in_SPI1_CLOCK(pps_input_t VAR_0);
extern void pps_in_SPI1_DATA_IN(pps_input_t VAR_0);
extern void pps_in_SPI1_SS(pps_input_t VAR_0);
extern void FUNC_16(pps_input_t VAR_0); //* Q43 only
extern void pps_in_SPI2_DATA_IN(pps_input_t VAR_0); //* Q43 only
extern void FUNC_17(pps_input_t VAR_0); //* Q43 only
/* -------------------------------------------------------------------------- */
extern void pps_in_I2C1_CLOCK(pps_input_t VAR_0);
extern void FUNC_18(pps_input_t VAR_0);
extern void FUNC_19(pps_input_t VAR_0); //* K42 only
extern void pps_in_I2C2_DATA(pps_input_t VAR_0); //* K42 only
/* -------------------------------------------------------------------------- */
extern void pps_in_UART1_RX(pps_input_t VAR_0);
extern void pps_in_UART1_CTS(pps_input_t VAR_0);
extern void pps_in_UART2_RX(pps_input_t VAR_0);
extern void pps_in_UART2_CTS(pps_input_t VAR_0);
extern void FUNC_20(pps_input_t VAR_0); //* Q43 only
extern void pps_in_UART3_CTS(pps_input_t VAR_0); //* Q43 only
extern void pps_in_UART4_RX(pps_input_t VAR_0); //* Q43 only
extern void pps_in_UART4_CTS(pps_input_t VAR_0); //* Q43 only
extern void pps_in_UART5_RX(pps_input_t VAR_0); //* Q43 only
extern void FUNC_21(pps_input_t VAR_0); //* Q43 only
/* ************************************************************************** */
/* PPS Output Registers
Example PPS Output assignments:
Assigning UART1 TX to pin RC6:
pps_out_UART1_TX(RC6PPS)
Assigning the output of PWM5 to RB2, through a function call:
void some_init(pps_output_t* outputPin){
pps_out_PWM5(outputPin);
}
void some_other_function(void) {
some_init(PPS_OUT(B, 2));
}
*/
// Can be used to pass PPS pins into a function
typedef volatile unsigned char ID_0;
//
#define PPS_OUTPUT(port, VAR_0) (&R##port##pin##PPS)
/* -------------------------------------------------------------------------- */
// ADC Guard Ring Outputs
extern void pps_out_ADC_GUARD_RING_B(CLASS_0 *VAR_0);
extern void FUNC_22(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// Complementary Waveform Generator 3
extern void pps_out_CWG3D(CLASS_0 *VAR_0);
extern void pps_out_CWG3C(CLASS_0 *VAR_0);
extern void pps_out_CWG3B(CLASS_0 *VAR_0);
extern void FUNC_23(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// Complementary Waveform Generator 3
extern void pps_out_CWG2D(CLASS_0 *VAR_0);
extern void pps_out_CWG2C(CLASS_0 *VAR_0);
extern void FUNC_24(CLASS_0 *VAR_0);
extern void pps_out_CWG2A(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// Complementary Waveform Generator 3
extern void pps_out_CWG1D(CLASS_0 *VAR_0);
extern void pps_out_CWG1C(CLASS_0 *VAR_0);
extern void pps_out_CWG1B(CLASS_0 *VAR_0);
extern void FUNC_25(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// Digital Signal Modulater
extern void pps_out_DSM1(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// Reference Clock Output
extern void pps_out_CLKR(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// Numerically Controller Oscillator
extern void pps_out_NCO3(CLASS_0 *VAR_0); //* Q43 only
extern void FUNC_26(CLASS_0 *VAR_0); //* Q43 only
extern void FUNC_27(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// Timer 0 Output
extern void FUNC_28(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// I2C
extern void pps_out_I2C1_DATA(CLASS_0 *VAR_0);
extern void FUNC_29(CLASS_0 *VAR_0);
extern void pps_out_I2C2_DATA(CLASS_0 *VAR_0); //* K42 only
extern void pps_out_I2C2_CLOCK(CLASS_0 *VAR_0); //* K42 only
/* -------------------------------------------------------------------------- */
// SPI
extern void FUNC_30(CLASS_0 *VAR_0);
extern void pps_out_SPI1_DATA_OUT(CLASS_0 *VAR_0);
extern void pps_out_SPI1_CLOCK(CLASS_0 *VAR_0);
extern void pps_out_SPI2_SS(CLASS_0 *VAR_0); //* Q43 only
extern void pps_out_SPI2_DATA_OUT(CLASS_0 *VAR_0); //* Q43 only
extern void pps_out_SPI2_CLOCK(CLASS_0 *VAR_0); //* Q43 only
/* -------------------------------------------------------------------------- */
// Comparator
extern void pps_out_COMPARATOR_2(CLASS_0 *VAR_0);
extern void pps_out_COMPARATOR_1(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// UART 5
extern void FUNC_31(CLASS_0 *VAR_0); //* Q43 only
extern void pps_out_UART5_TXDE(CLASS_0 *VAR_0); //* Q43 only
extern void FUNC_32(CLASS_0 *VAR_0); //* Q43 only
/* -------------------------------------------------------------------------- */
// UART 4
extern void pps_out_UART4_RTS(CLASS_0 *VAR_0); //* Q43 only
extern void FUNC_33(CLASS_0 *VAR_0); //* Q43 only
extern void FUNC_34(CLASS_0 *VAR_0); //* Q43 only
/* -------------------------------------------------------------------------- */
// UART 3
extern void pps_out_UART3_RTS(CLASS_0 *VAR_0); //* Q43 only
extern void pps_out_UART3_TXDE(CLASS_0 *VAR_0); //* Q43 only
extern void pps_out_UART3_TX(CLASS_0 *VAR_0); //* Q43 only
/* -------------------------------------------------------------------------- */
// UART 2
extern void pps_out_UART2_RTS(CLASS_0 *VAR_0);
extern void FUNC_35(CLASS_0 *VAR_0);
extern void FUNC_36(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// UART 1
extern void pps_out_UART1_RTS(CLASS_0 *VAR_0);
extern void pps_out_UART1_TXDE(CLASS_0 *VAR_0);
extern void FUNC_37(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// PWM
extern void pps_out_PWM8(CLASS_0 *VAR_0); //* K42 only
extern void pps_out_PWM7(CLASS_0 *VAR_0); //* K42 only
extern void pps_out_PWM6(CLASS_0 *VAR_0); //* K42 only
extern void pps_out_PWM5(CLASS_0 *VAR_0); //* K42 only
extern void pps_out_PWM3S1P2(CLASS_0 *VAR_0); //* Q43 only
extern void pps_out_PWM3S1P1(CLASS_0 *VAR_0); //* Q43 only
extern void pps_out_PWM2S1P2(CLASS_0 *VAR_0); //* Q43 only
extern void FUNC_38(CLASS_0 *VAR_0); //* Q43 only
extern void FUNC_39(CLASS_0 *VAR_0); //* Q43 only
extern void pps_out_PWM1S1P1(CLASS_0 *VAR_0); //* Q43 only
/* -------------------------------------------------------------------------- */
// Capture/Compare
extern void pps_out_CCP4(CLASS_0 *VAR_0); //* K42 only
extern void pps_out_CCP3(CLASS_0 *VAR_0);
extern void FUNC_40(CLASS_0 *VAR_0);
extern void pps_out_CCP1(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// Configurable Logic Cell
extern void FUNC_41(CLASS_0 *VAR_0); //* Q43 only
extern void FUNC_42(CLASS_0 *VAR_0); //* Q43 only
extern void pps_out_CLC6_OUTPUT(CLASS_0 *VAR_0); //* Q43 only
extern void pps_out_CLC5_OUTPUT(CLASS_0 *VAR_0); //* Q43 only
extern void pps_out_CLC4_OUTPUT(CLASS_0 *VAR_0);
extern void FUNC_43(CLASS_0 *VAR_0);
extern void pps_out_CLC2_OUTPUT(CLASS_0 *VAR_0);
extern void FUNC_44(CLASS_0 *VAR_0);
/* -------------------------------------------------------------------------- */
// Default value of all RXYPPS registers at RESET
// Primarily used to revert a PPS configuration
extern void pps_out_LATCH(CLASS_0 *VAR_0);
/* ************************************************************************** */
#endif /* _PPS_H_ */ | 0.395734 | {'FUNC_0': 'pps_unlock', 'VAR_0': 'pin', 'VAR_1': 'PPS_PORT_B', 'VAR_2': 'PPS_PORT_C', 'VAR_3': 'PPS_PORT_E', 'VAR_4': 'PPS_PIN_2', 'VAR_5': 'PPS_PIN_6', 'VAR_6': 'PPS_PIN_7', 'FUNC_1': 'pps_in_INTERRUPT1', 'FUNC_2': 'pps_in_INTERRUPT2', 'FUNC_3': 'pps_in_TIMER1_GATE', 'FUNC_4': 'pps_in_CCP2', 'FUNC_5': 'pps_in_CCP3', 'FUNC_6': 'pps_in_PWM_Input_1', 'FUNC_7': 'pps_in_SMT1_WINDOW', 'FUNC_8': 'pps_in_SMT1_SIGNAL', 'FUNC_9': 'pps_in_CWG2', 'FUNC_10': 'pps_in_DSM_CARRIER_LOW', 'FUNC_11': 'pps_in_DSM_CARRIER_HIGH', 'FUNC_12': 'pps_in_DSM_SOURCE', 'FUNC_13': 'pps_in_CLC2_INPUT', 'FUNC_14': 'pps_in_CLC4_INPUT', 'FUNC_15': 'pps_in_ADC_TRIGGER', 'FUNC_16': 'pps_in_SPI2_CLOCK', 'FUNC_17': 'pps_in_SPI2_SS', 'FUNC_18': 'pps_in_I2C1_DATA', 'FUNC_19': 'pps_in_I2C2_CLOCK', 'FUNC_20': 'pps_in_UART3_RX', 'FUNC_21': 'pps_in_UART5_CTS', 'ID_0': 'pps_output_t', 'CLASS_0': 'pps_output_t', 'FUNC_22': 'pps_out_ADC_GUARD_RING_A', 'FUNC_23': 'pps_out_CWG3A', 'FUNC_24': 'pps_out_CWG2B', 'FUNC_25': 'pps_out_CWG1A', 'FUNC_26': 'pps_out_NCO2', 'FUNC_27': 'pps_out_NCO1', 'FUNC_28': 'pps_out_TIMER0', 'FUNC_29': 'pps_out_I2C1_CLOCK', 'FUNC_30': 'pps_out_SPI1_SS', 'FUNC_31': 'pps_out_UART5_RTS', 'FUNC_32': 'pps_out_UART5_TX', 'FUNC_33': 'pps_out_UART4_TXDE', 'FUNC_34': 'pps_out_UART4_TX', 'FUNC_35': 'pps_out_UART2_TXDE', 'FUNC_36': 'pps_out_UART2_TX', 'FUNC_37': 'pps_out_UART1_TX', 'FUNC_38': 'pps_out_PWM2S1P1', 'FUNC_39': 'pps_out_PWM1S1P2', 'FUNC_40': 'pps_out_CCP2', 'FUNC_41': 'pps_out_CLC8_OUTPUT', 'FUNC_42': 'pps_out_CLC7_OUTPUT', 'FUNC_43': 'pps_out_CLC3_OUTPUT', 'FUNC_44': 'pps_out_CLC1_OUTPUT'} |
/*
* (C) Copyright 2000-2004
* <NAME>, DENX Software Engineering, <EMAIL>.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef _PART_H
#define _PART_H
#include <ide.h>
typedef struct block_dev_desc {
int if_type; /* type of the interface */
int dev; /* device number */
unsigned char part_type; /* partition type */
unsigned char target; /* target SCSI ID */
unsigned char lun; /* target LUN */
unsigned char type; /* device type */
unsigned char removable; /* removable device */
#ifdef CONFIG_LBA48
unsigned char lba48; /* device can use 48bit addr (ATA/ATAPI v7) */
#endif
lbaint_t lba; /* number of blocks */
unsigned long blksz; /* block size */
char vendor [40+1]; /* IDE model, SCSI Vendor */
char product[20+1]; /* IDE Serial no, SCSI product */
char revision[8+1]; /* firmware revision */
unsigned long (*block_read)(int dev,
unsigned long start,
lbaint_t blkcnt,
void *buffer);
unsigned long (*block_write)(int dev,
unsigned long start,
lbaint_t blkcnt,
const void *buffer);
unsigned long (*block_erase)(int dev,
unsigned long start,
lbaint_t blkcnt);
void *priv; /* driver private struct pointer */
}block_dev_desc_t;
/* Interface types: */
#define IF_TYPE_UNKNOWN 0
#define IF_TYPE_IDE 1
#define IF_TYPE_SCSI 2
#define IF_TYPE_ATAPI 3
#define IF_TYPE_USB 4
#define IF_TYPE_DOC 5
#define IF_TYPE_MMC 6
#define IF_TYPE_SD 7
#define IF_TYPE_SATA 8
/* Part types */
#define PART_TYPE_UNKNOWN 0x00
#define PART_TYPE_MAC 0x01
#define PART_TYPE_DOS 0x02
#define PART_TYPE_ISO 0x03
#define PART_TYPE_AMIGA 0x04
#define PART_TYPE_EFI 0x05
/*
* Type string for U-Boot bootable partitions
*/
#define BOOT_PART_TYPE "U-Boot" /* primary boot partition type */
#define BOOT_PART_COMP "PPCBoot" /* PPCBoot compatibility type */
/* device types */
#define DEV_TYPE_UNKNOWN 0xff /* not connected */
#define DEV_TYPE_HARDDISK 0x00 /* harddisk */
#define DEV_TYPE_TAPE 0x01 /* Tape */
#define DEV_TYPE_CDROM 0x05 /* CD-ROM */
#define DEV_TYPE_OPDISK 0x07 /* optical disk */
typedef struct disk_partition {
ulong start; /* # of first block in partition */
ulong size; /* number of blocks in partition */
ulong blksz; /* block size in bytes */
uchar name[32]; /* partition name */
uchar type[32]; /* string type description */
int bootable; /* Active/Bootable flag is set */
#ifdef CONFIG_PARTITION_UUIDS
char uuid[37]; /* filesystem UUID as string, if exists */
#endif
} disk_partition_t;
/* Misc _get_dev functions */
#ifdef CONFIG_PARTITIONS
block_dev_desc_t *get_dev(const char *ifname, int dev);
block_dev_desc_t* ide_get_dev(int dev);
block_dev_desc_t* sata_get_dev(int dev);
block_dev_desc_t* scsi_get_dev(int dev);
block_dev_desc_t* usb_stor_get_dev(int dev);
block_dev_desc_t* mmc_get_dev(int dev);
block_dev_desc_t* systemace_get_dev(int dev);
block_dev_desc_t* mg_disk_get_dev(int dev);
/* disk/part.c */
int get_partition_info (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part (block_dev_desc_t *dev_desc);
void init_part (block_dev_desc_t *dev_desc);
void dev_print(block_dev_desc_t *dev_desc);
int get_device(const char *ifname, const char *dev_str,
block_dev_desc_t **dev_desc);
int get_device_and_partition(const char *ifname, const char *dev_part_str,
block_dev_desc_t **dev_desc,
disk_partition_t *info, int allow_whole_dev);
#else
static inline block_dev_desc_t *get_dev(const char *ifname, int dev)
{ return NULL; }
static inline block_dev_desc_t* ide_get_dev(int dev) { return NULL; }
static inline block_dev_desc_t* sata_get_dev(int dev) { return NULL; }
static inline block_dev_desc_t* scsi_get_dev(int dev) { return NULL; }
static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; }
static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; }
static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; }
static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; }
static inline int get_partition_info (block_dev_desc_t * dev_desc, int part,
disk_partition_t *info) { return -1; }
static inline void print_part (block_dev_desc_t *dev_desc) {}
static inline void init_part (block_dev_desc_t *dev_desc) {}
static inline void dev_print(block_dev_desc_t *dev_desc) {}
static inline int get_device(const char *ifname, const char *dev_str,
block_dev_desc_t **dev_desc)
{ return -1; }
static inline int get_device_and_partition(const char *ifname,
const char *dev_part_str,
block_dev_desc_t **dev_desc,
disk_partition_t *info,
int allow_whole_dev)
{ *dev_desc = NULL; return -1; }
#endif
#ifdef CONFIG_MAC_PARTITION
/* disk/part_mac.c */
int get_partition_info_mac (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part_mac (block_dev_desc_t *dev_desc);
int test_part_mac (block_dev_desc_t *dev_desc);
#endif
#ifdef CONFIG_DOS_PARTITION
/* disk/part_dos.c */
int get_partition_info_dos (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part_dos (block_dev_desc_t *dev_desc);
int test_part_dos (block_dev_desc_t *dev_desc);
#endif
#ifdef CONFIG_ISO_PARTITION
/* disk/part_iso.c */
int get_partition_info_iso (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part_iso (block_dev_desc_t *dev_desc);
int test_part_iso (block_dev_desc_t *dev_desc);
#endif
#ifdef CONFIG_AMIGA_PARTITION
/* disk/part_amiga.c */
int get_partition_info_amiga (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part_amiga (block_dev_desc_t *dev_desc);
int test_part_amiga (block_dev_desc_t *dev_desc);
#endif
#ifdef CONFIG_EFI_PARTITION
#include <part_efi.h>
/* disk/part_efi.c */
int get_partition_info_efi (block_dev_desc_t * dev_desc, int part, disk_partition_t *info);
void print_part_efi (block_dev_desc_t *dev_desc);
int test_part_efi (block_dev_desc_t *dev_desc);
/**
* write_gpt_table() - Write the GUID Partition Table to disk
*
* @param dev_desc - block device descriptor
* @param gpt_h - pointer to GPT header representation
* @param gpt_e - pointer to GPT partition table entries
*
* @return - zero on success, otherwise error
*/
int write_gpt_table(block_dev_desc_t *dev_desc,
gpt_header *gpt_h, gpt_entry *gpt_e);
/**
* gpt_fill_pte(): Fill the GPT partition table entry
*
* @param gpt_h - GPT header representation
* @param gpt_e - GPT partition table entries
* @param partitions - list of partitions
* @param parts - number of partitions
*
* @return zero on success
*/
int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
disk_partition_t *partitions, int parts);
/**
* gpt_fill_header(): Fill the GPT header
*
* @param dev_desc - block device descriptor
* @param gpt_h - GPT header representation
* @param str_guid - disk guid string representation
* @param parts_count - number of partitions
*
* @return - error on str_guid conversion error
*/
int gpt_fill_header(block_dev_desc_t *dev_desc, gpt_header *gpt_h,
char *str_guid, int parts_count);
/**
* gpt_restore(): Restore GPT partition table
*
* @param dev_desc - block device descriptor
* @param str_disk_guid - disk GUID
* @param partitions - list of partitions
* @param parts - number of partitions
*
* @return zero on success
*/
int gpt_restore(block_dev_desc_t *dev_desc, char *str_disk_guid,
disk_partition_t *partitions, const int parts_count);
#endif
#endif /* _PART_H */
| /*
* (C) Copyright 2000-2004
* <NAME>, DENX Software Engineering, <EMAIL>.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef VAR_0
#define VAR_0
#include <IMPORT_0>
typedef struct CLASS_0 {
int VAR_1; /* type of the interface */
int VAR_2; /* device number */
unsigned char VAR_3; /* partition type */
unsigned char VAR_4; /* target SCSI ID */
unsigned char lun; /* target LUN */
unsigned char VAR_5; /* device type */
unsigned char removable; /* removable device */
#ifdef VAR_6
unsigned char VAR_7; /* device can use 48bit addr (ATA/ATAPI v7) */
#endif
CLASS_1 VAR_8; /* number of blocks */
unsigned long VAR_9; /* block size */
char VAR_10 [40+1]; /* IDE model, SCSI Vendor */
char VAR_11[20+1]; /* IDE Serial no, SCSI product */
char VAR_12[8+1]; /* firmware revision */
unsigned long (*FUNC_0)(int VAR_2,
unsigned long VAR_13,
CLASS_1 blkcnt,
void *VAR_14);
unsigned long (*FUNC_1)(int VAR_2,
unsigned long VAR_13,
CLASS_1 blkcnt,
const void *VAR_14);
unsigned long (*block_erase)(int VAR_2,
unsigned long VAR_13,
CLASS_1 blkcnt);
void *VAR_15; /* driver private struct pointer */
}block_dev_desc_t;
/* Interface types: */
#define VAR_16 0
#define VAR_17 1
#define VAR_18 2
#define VAR_19 3
#define VAR_20 4
#define VAR_21 5
#define VAR_22 6
#define VAR_23 7
#define VAR_24 8
/* Part types */
#define VAR_25 0x00
#define VAR_26 0x01
#define VAR_27 0x02
#define VAR_28 0x03
#define VAR_29 0x04
#define VAR_30 0x05
/*
* Type string for U-Boot bootable partitions
*/
#define VAR_31 "U-Boot" /* primary boot partition type */
#define VAR_32 "PPCBoot" /* PPCBoot compatibility type */
/* device types */
#define VAR_33 0xff /* not connected */
#define DEV_TYPE_HARDDISK 0x00 /* harddisk */
#define VAR_34 0x01 /* Tape */
#define VAR_35 0x05 /* CD-ROM */
#define VAR_36 0x07 /* optical disk */
typedef struct CLASS_2 {
CLASS_3 VAR_13; /* # of first block in partition */
CLASS_3 size; /* number of blocks in partition */
CLASS_3 VAR_9; /* block size in bytes */
CLASS_4 VAR_37[32]; /* partition name */
CLASS_4 VAR_5[32]; /* string type description */
int VAR_38; /* Active/Bootable flag is set */
#ifdef VAR_39
char VAR_40[37]; /* filesystem UUID as string, if exists */
#endif
} ID_0;
/* Misc _get_dev functions */
#ifdef CONFIG_PARTITIONS
block_dev_desc_t *get_dev(const char *ifname, int VAR_2);
block_dev_desc_t* FUNC_2(int VAR_2);
block_dev_desc_t* FUNC_3(int VAR_2);
block_dev_desc_t* FUNC_4(int VAR_2);
block_dev_desc_t* FUNC_5(int VAR_2);
block_dev_desc_t* mmc_get_dev(int VAR_2);
block_dev_desc_t* FUNC_6(int VAR_2);
block_dev_desc_t* FUNC_7(int VAR_2);
/* disk/part.c */
int FUNC_8 (block_dev_desc_t * VAR_41, int VAR_42, CLASS_5 *VAR_43);
void FUNC_9 (block_dev_desc_t *VAR_41);
void FUNC_10 (block_dev_desc_t *VAR_41);
void FUNC_11(block_dev_desc_t *VAR_41);
int FUNC_12(const char *ifname, const char *VAR_44,
block_dev_desc_t **VAR_41);
int FUNC_13(const char *ifname, const char *dev_part_str,
block_dev_desc_t **VAR_41,
CLASS_5 *VAR_43, int VAR_45);
#else
static inline block_dev_desc_t *get_dev(const char *ifname, int VAR_2)
{ return NULL; }
static inline block_dev_desc_t* FUNC_2(int VAR_2) { return NULL; }
static inline block_dev_desc_t* FUNC_3(int VAR_2) { return NULL; }
static inline block_dev_desc_t* FUNC_4(int VAR_2) { return NULL; }
static inline block_dev_desc_t* FUNC_5(int VAR_2) { return NULL; }
static inline block_dev_desc_t* mmc_get_dev(int VAR_2) { return NULL; }
static inline block_dev_desc_t* FUNC_6(int VAR_2) { return NULL; }
static inline block_dev_desc_t* FUNC_7(int VAR_2) { return NULL; }
static inline int FUNC_8 (block_dev_desc_t * VAR_41, int VAR_42,
CLASS_5 *VAR_43) { return -1; }
static inline void FUNC_9 (block_dev_desc_t *VAR_41) {}
static inline void FUNC_10 (block_dev_desc_t *VAR_41) {}
static inline void FUNC_11(block_dev_desc_t *VAR_41) {}
static inline int FUNC_12(const char *ifname, const char *VAR_44,
block_dev_desc_t **VAR_41)
{ return -1; }
static inline int FUNC_13(const char *ifname,
const char *dev_part_str,
block_dev_desc_t **VAR_41,
CLASS_5 *VAR_43,
int VAR_45)
{ *VAR_41 = NULL; return -1; }
#endif
#ifdef VAR_46
/* disk/part_mac.c */
int FUNC_14 (block_dev_desc_t * VAR_41, int VAR_42, CLASS_5 *VAR_43);
void FUNC_15 (block_dev_desc_t *VAR_41);
int FUNC_16 (block_dev_desc_t *VAR_41);
#endif
#ifdef VAR_47
/* disk/part_dos.c */
int FUNC_17 (block_dev_desc_t * VAR_41, int VAR_42, CLASS_5 *VAR_43);
void FUNC_18 (block_dev_desc_t *VAR_41);
int FUNC_19 (block_dev_desc_t *VAR_41);
#endif
#ifdef VAR_48
/* disk/part_iso.c */
int FUNC_20 (block_dev_desc_t * VAR_41, int VAR_42, CLASS_5 *VAR_43);
void FUNC_21 (block_dev_desc_t *VAR_41);
int test_part_iso (block_dev_desc_t *VAR_41);
#endif
#ifdef VAR_49
/* disk/part_amiga.c */
int FUNC_22 (block_dev_desc_t * VAR_41, int VAR_42, CLASS_5 *VAR_43);
void FUNC_23 (block_dev_desc_t *VAR_41);
int FUNC_24 (block_dev_desc_t *VAR_41);
#endif
#ifdef VAR_50
#include <IMPORT_1>
/* disk/part_efi.c */
int FUNC_25 (block_dev_desc_t * VAR_41, int VAR_42, CLASS_5 *VAR_43);
void FUNC_26 (block_dev_desc_t *VAR_41);
int FUNC_27 (block_dev_desc_t *VAR_41);
/**
* write_gpt_table() - Write the GUID Partition Table to disk
*
* @param dev_desc - block device descriptor
* @param gpt_h - pointer to GPT header representation
* @param gpt_e - pointer to GPT partition table entries
*
* @return - zero on success, otherwise error
*/
int FUNC_28(block_dev_desc_t *VAR_41,
gpt_header *VAR_51, CLASS_6 *VAR_52);
/**
* gpt_fill_pte(): Fill the GPT partition table entry
*
* @param gpt_h - GPT header representation
* @param gpt_e - GPT partition table entries
* @param partitions - list of partitions
* @param parts - number of partitions
*
* @return zero on success
*/
int FUNC_29(gpt_header *VAR_51, CLASS_6 *VAR_52,
CLASS_5 *VAR_53, int parts);
/**
* gpt_fill_header(): Fill the GPT header
*
* @param dev_desc - block device descriptor
* @param gpt_h - GPT header representation
* @param str_guid - disk guid string representation
* @param parts_count - number of partitions
*
* @return - error on str_guid conversion error
*/
int FUNC_30(block_dev_desc_t *VAR_41, gpt_header *VAR_51,
char *VAR_54, int VAR_55);
/**
* gpt_restore(): Restore GPT partition table
*
* @param dev_desc - block device descriptor
* @param str_disk_guid - disk GUID
* @param partitions - list of partitions
* @param parts - number of partitions
*
* @return zero on success
*/
int gpt_restore(block_dev_desc_t *VAR_41, char *VAR_56,
CLASS_5 *VAR_53, const int VAR_55);
#endif
#endif /* _PART_H */
| 0.890367 | {'VAR_0': '_PART_H', 'IMPORT_0': 'ide.h', 'CLASS_0': 'block_dev_desc', 'VAR_1': 'if_type', 'VAR_2': 'dev', 'VAR_3': 'part_type', 'VAR_4': 'target', 'VAR_5': 'type', 'VAR_6': 'CONFIG_LBA48', 'VAR_7': 'lba48', 'CLASS_1': 'lbaint_t', 'VAR_8': 'lba', 'VAR_9': 'blksz', 'VAR_10': 'vendor', 'VAR_11': 'product', 'VAR_12': 'revision', 'FUNC_0': 'block_read', 'VAR_13': 'start', 'VAR_14': 'buffer', 'FUNC_1': 'block_write', 'VAR_15': 'priv', 'VAR_16': 'IF_TYPE_UNKNOWN', 'VAR_17': 'IF_TYPE_IDE', 'VAR_18': 'IF_TYPE_SCSI', 'VAR_19': 'IF_TYPE_ATAPI', 'VAR_20': 'IF_TYPE_USB', 'VAR_21': 'IF_TYPE_DOC', 'VAR_22': 'IF_TYPE_MMC', 'VAR_23': 'IF_TYPE_SD', 'VAR_24': 'IF_TYPE_SATA', 'VAR_25': 'PART_TYPE_UNKNOWN', 'VAR_26': 'PART_TYPE_MAC', 'VAR_27': 'PART_TYPE_DOS', 'VAR_28': 'PART_TYPE_ISO', 'VAR_29': 'PART_TYPE_AMIGA', 'VAR_30': 'PART_TYPE_EFI', 'VAR_31': 'BOOT_PART_TYPE', 'VAR_32': 'BOOT_PART_COMP', 'VAR_33': 'DEV_TYPE_UNKNOWN', 'VAR_34': 'DEV_TYPE_TAPE', 'VAR_35': 'DEV_TYPE_CDROM', 'VAR_36': 'DEV_TYPE_OPDISK', 'CLASS_2': 'disk_partition', 'CLASS_3': 'ulong', 'CLASS_4': 'uchar', 'VAR_37': 'name', 'VAR_38': 'bootable', 'VAR_39': 'CONFIG_PARTITION_UUIDS', 'VAR_40': 'uuid', 'ID_0': 'disk_partition_t', 'CLASS_5': 'disk_partition_t', 'FUNC_2': 'ide_get_dev', 'FUNC_3': 'sata_get_dev', 'FUNC_4': 'scsi_get_dev', 'FUNC_5': 'usb_stor_get_dev', 'FUNC_6': 'systemace_get_dev', 'FUNC_7': 'mg_disk_get_dev', 'FUNC_8': 'get_partition_info', 'VAR_41': 'dev_desc', 'VAR_42': 'part', 'VAR_43': 'info', 'FUNC_9': 'print_part', 'FUNC_10': 'init_part', 'FUNC_11': 'dev_print', 'FUNC_12': 'get_device', 'VAR_44': 'dev_str', 'FUNC_13': 'get_device_and_partition', 'VAR_45': 'allow_whole_dev', 'VAR_46': 'CONFIG_MAC_PARTITION', 'FUNC_14': 'get_partition_info_mac', 'FUNC_15': 'print_part_mac', 'FUNC_16': 'test_part_mac', 'VAR_47': 'CONFIG_DOS_PARTITION', 'FUNC_17': 'get_partition_info_dos', 'FUNC_18': 'print_part_dos', 'FUNC_19': 'test_part_dos', 'VAR_48': 'CONFIG_ISO_PARTITION', 'FUNC_20': 'get_partition_info_iso', 'FUNC_21': 'print_part_iso', 'VAR_49': 'CONFIG_AMIGA_PARTITION', 'FUNC_22': 'get_partition_info_amiga', 'FUNC_23': 'print_part_amiga', 'FUNC_24': 'test_part_amiga', 'VAR_50': 'CONFIG_EFI_PARTITION', 'IMPORT_1': 'part_efi.h', 'FUNC_25': 'get_partition_info_efi', 'FUNC_26': 'print_part_efi', 'FUNC_27': 'test_part_efi', 'FUNC_28': 'write_gpt_table', 'VAR_51': 'gpt_h', 'CLASS_6': 'gpt_entry', 'VAR_52': 'gpt_e', 'FUNC_29': 'gpt_fill_pte', 'VAR_53': 'partitions', 'FUNC_30': 'gpt_fill_header', 'VAR_54': 'str_guid', 'VAR_55': 'parts_count', 'VAR_56': 'str_disk_guid'} |
#include <stdio.h>
long n;
void nhap()
{
long dem=0,i=1,j;
scanf("%d",&n);
while ((dem+i*5)<n)
{
dem+=i*5;
i*=2;
}
j=1;
while (i+dem<n)
{
dem+=i;
j++;
}
if (j==1) printf("Sheldon");
if (j==2) printf("Leonard");
if (j==3) printf("Penny");
if (j==4) printf("Rajesh");
if (j==5) printf("Howard");
}
int main()
{
nhap();
return 0;
}
| #include <stdio.h>
long n;
void FUNC_0()
{
long dem=0,VAR_0=1,VAR_1;
scanf("%d",&n);
while ((dem+VAR_0*5)<n)
{
dem+=VAR_0*5;
VAR_0*=2;
}
VAR_1=1;
while (VAR_0+dem<n)
{
dem+=VAR_0;
VAR_1++;
}
if (VAR_1==1) printf("Sheldon");
if (VAR_1==2) printf("Leonard");
if (VAR_1==3) printf("Penny");
if (VAR_1==4) printf("Rajesh");
if (VAR_1==5) printf("Howard");
}
int FUNC_1()
{
FUNC_0();
return 0;
}
| 0.162476 | {'FUNC_0': 'nhap', 'VAR_0': 'i', 'VAR_1': 'j', 'FUNC_1': 'main'} |
/*
* This file is part of the Simutrans-Extended project under the Artistic License.
* (see LICENSE.txt)
*/
#ifndef GUI_FACTORYLIST_STATS_T_H
#define GUI_FACTORYLIST_STATS_T_H
#include "../tpl/vector_tpl.h"
#include "components/gui_component.h"
class fabrik_t;
namespace factorylist {
enum sort_mode_t {
by_name = 0,
by_available,
by_output,
by_maxprod,
by_status,
by_power,
by_sector,
by_staffing,
by_operation_rate,
by_region,
SORT_MODES,
// the last two are unused
by_input,
by_transit
};
};
/**
* Factory list stats display
* Where factory stats are calculated for list dialog
*/
class factorylist_stats_t : public gui_world_component_t
{
private:
vector_tpl<fabrik_t*> fab_list;
uint32 line_selected;
factorylist::sort_mode_t sortby;
bool sortreverse;
bool filter_own_network;
uint8 filter_goods_catg;
public:
factorylist_stats_t(factorylist::sort_mode_t sortby, bool sortreverse, bool own_network, uint8 goods_catg_index);
void sort(factorylist::sort_mode_t sortby, bool sortreverse, bool own_network, uint8 goods_catg_index);
uint8 display_mode = 0;
bool infowin_event(event_t const*) OVERRIDE;
/**
* Recalc the size required to display everything and set size (size).
*/
void recalc_size();
/* char const* get_text() const OVERRIDE { return fab->get_name(); }
bool infowin_event(const event_t *) OVERRIDE;
bool is_valid() const OVERRIDE;
void set_size(scr_size size) OVERRIDE;
*/
void draw(scr_coord offset) OVERRIDE;
};
#endif
| /*
* This file is part of the Simutrans-Extended project under the Artistic License.
* (see LICENSE.txt)
*/
#ifndef GUI_FACTORYLIST_STATS_T_H
#define GUI_FACTORYLIST_STATS_T_H
#include "IMPORT_0"
#include "components/gui_component.h"
CLASS_0 fabrik_t;
namespace factorylist {
enum CLASS_1 {
VAR_1 = 0,
by_available,
by_output,
VAR_2,
VAR_3,
VAR_4,
by_sector,
by_staffing,
VAR_5,
VAR_6,
VAR_7,
// the last two are unused
VAR_8,
by_transit
};
};
/**
* Factory list stats display
* Where factory stats are calculated for list dialog
*/
CLASS_0 VAR_9 : VAR_10 VAR_11
{
private:
VAR_12<fabrik_t*> fab_list;
CLASS_2 VAR_13;
factorylist::VAR_0 sortby;
bool sortreverse;
bool VAR_14;
uint8 filter_goods_catg;
public:
FUNC_0(factorylist::VAR_0 sortby, VAR_15 sortreverse, VAR_15 VAR_16, uint8 VAR_17);
void sort(factorylist::VAR_0 sortby, bool sortreverse, bool VAR_16, uint8 VAR_17);
uint8 display_mode = 0;
bool FUNC_1(CLASS_3 const*) OVERRIDE;
/**
* Recalc the size required to display everything and set size (size).
*/
void recalc_size();
/* char const* get_text() const OVERRIDE { return fab->get_name(); }
bool infowin_event(const event_t *) OVERRIDE;
bool is_valid() const OVERRIDE;
void set_size(scr_size size) OVERRIDE;
*/
void FUNC_2(scr_coord offset) OVERRIDE;
};
#endif
| 0.428189 | {'IMPORT_0': '../tpl/vector_tpl.h', 'CLASS_0': 'class', 'CLASS_1': 'sort_mode_t', 'VAR_0': 'sort_mode_t', 'VAR_1': 'by_name', 'VAR_2': 'by_maxprod', 'VAR_3': 'by_status', 'VAR_4': 'by_power', 'VAR_5': 'by_operation_rate', 'VAR_6': 'by_region', 'VAR_7': 'SORT_MODES', 'VAR_8': 'by_input', 'VAR_9': 'factorylist_stats_t', 'FUNC_0': 'factorylist_stats_t', 'VAR_10': 'public', 'VAR_11': 'gui_world_component_t', 'VAR_12': 'vector_tpl', 'CLASS_2': 'uint32', 'VAR_13': 'line_selected', 'VAR_14': 'filter_own_network', 'VAR_15': 'bool', 'VAR_16': 'own_network', 'VAR_17': 'goods_catg_index', 'FUNC_1': 'infowin_event', 'CLASS_3': 'event_t', 'FUNC_2': 'draw'} |
/**************************************************************************
* National Semiconductor COP410 Emulator *
* *
* Copyright (C) 2006 MAME Team *
**************************************************************************/
#define ROM(A) cpu_readop(A)
#define RAM_W(A,V) (data_write_byte_8(A,V))
#define RAM_R(A) (data_read_byte_8(A))
#define IN(A) io_read_byte_8(A)
#define OUT(A,V) io_write_byte_8(A,V)
#define A R.A
#define B R.B
#define C R.C
#define G R.G
#define Q R.Q
#define EN R.EN
#define SA R.SA
#define SB R.SB
#define SIO R.SIO
#define SKL R.SKL
#define PC R.PC
#define prevPC R.PREVPC
#define skip R.skip
#define skipLBI R.skipLBI
#define READ_M RAM_R(B)
#define WRITE_M(VAL) RAM_W(B,VAL)
#define IN_G() IN(COP400_PORT_G)
#define IN_L() IN(COP400_PORT_L)
#define OUT_G(A) OUT(COP400_PORT_G, (A) & R.G_mask)
#define OUT_L(A) OUT(COP400_PORT_L, (A))
#define OUT_D(A) OUT(COP400_PORT_D, (A) & R.D_mask)
#define OUT_SK(A) OUT(COP400_PORT_SK,A)
#ifndef PUSH
#define PUSH(addr) { SB = SA; SA = addr; }
#define POP() { PC = SA; SA = SB; }
#endif
INLINE void illegal(void)
{
logerror("ICOP400: PC = %04x, Illegal opcode = %02x\n", PC-1, ROM(PC-1));
}
INLINE void WRITE_SK(UINT8 data)
{
SKL = data;
if (EN & 0x01)
{
OUT_SK(SKL);
}
else
{
// NOT IMPLEMENTED
OUT_SK(SKL);
}
}
INLINE void WRITE_Q(UINT8 data)
{
Q = data;
if (EN & 0x04)
{
OUT_L(Q);
}
}
INLINE void WRITE_G(UINT8 data)
{
G = data;
OUT_G(G);
}
INLINE void add(void) { A = (A + RAM_R(B)) & 0x0F; }
INLINE void asc(void)
{
A = A + C + RAM_R(B);
if (A > 0xF)
{
C = 1;
skip = 1;
A &= 0xF;
}
else
{
C = 0;
}
}
INLINE void AISC(int y)
{
A = A + y;
if (A > 0xF)
{
skip = 1;
A &= 0xF;
}
}
INLINE void aisc1(void) { AISC(0x1); }
INLINE void aisc2(void) { AISC(0x2); }
INLINE void aisc3(void) { AISC(0x3); }
INLINE void aisc4(void) { AISC(0x4); }
INLINE void aisc5(void) { AISC(0x5); }
INLINE void aisc6(void) { AISC(0x6); }
INLINE void aisc7(void) { AISC(0x7); }
INLINE void aisc8(void) { AISC(0x8); }
INLINE void aisc9(void) { AISC(0x9); }
INLINE void aisc10(void) { AISC(0xA); }
INLINE void aisc11(void) { AISC(0xB); }
INLINE void aisc12(void) { AISC(0xC); }
INLINE void aisc13(void) { AISC(0xD); }
INLINE void aisc14(void) { AISC(0xE); }
INLINE void aisc15(void) { AISC(0xF); }
INLINE void cab(void) { B = (B & 0x30) | A; }
INLINE void camq(void) { WRITE_Q((A << 4) | READ_M); }
INLINE void cba(void) { A = B & 0xF; }
INLINE void clra(void){ A = 0; }
INLINE void comp(void) { A = A ^ 0xF; }
INLINE void ing(void) { A = IN_G(); }
INLINE void inl(void)
{
UINT8 L = IN_L();
RAM_W(B, L >> 4);
A = L & 0xF;
}
INLINE void jid(void)
{
UINT16 addr = (PC & 0x300) | (A << 4) | READ_M;
PC = (PC & 0x300) | ROM(addr);
}
INLINE void JMP(UINT8 a8)
{
PC = (a8 << 8) | ROM(PC);
}
INLINE void jmp0(void) { JMP(0); }
INLINE void jmp1(void) { JMP(1); }
INLINE void jmp2(void) { JMP(2); }
INLINE void jmp3(void) { JMP(3); }
INLINE void jp(void)
{
UINT8 op = ROM(prevPC);
if (((PC & 0x3E0) >= 0x80) && ((PC & 0x3E0) < 0x100)) //JP pages 2,3
{
PC = (UINT16)((PC & 0x380) | (op & 0x7F));
}
else
{
if ((op & 0xC0) == 0xC0) //JP other pages
{
PC = (UINT16)((PC & 0x3C0) | (op & 0x3F));
}
else //JSRP
{
PUSH((UINT16)(PC));
PC = (UINT16)(0x80 | (op & 0x3F));
}
}
}
INLINE void JSR(UINT8 a8)
{
PUSH(PC + 1);
PC = (a8 << 8) | ROM(PC);
}
INLINE void jsr0(void) { JSR(0); }
INLINE void jsr1(void) { JSR(1); }
INLINE void jsr2(void) { JSR(2); }
INLINE void jsr3(void) { JSR(3); }
INLINE void LD(UINT8 r)
{
A = RAM_R(B);
B = B ^ (r << 4);
}
INLINE void ld0(void) { LD(0); }
INLINE void ld1(void) { LD(1); }
INLINE void ld2(void) { LD(2); }
INLINE void ld3(void) { LD(3); }
INLINE void LBI(UINT8 r, UINT8 d)
{
B = (r << 4) | d;
skipLBI = 1;
}
INLINE void lbi0_0(void) { LBI(0,0); }
INLINE void lbi0_1(void) { LBI(0,1); }
INLINE void lbi0_2(void) { LBI(0,2); }
INLINE void lbi0_3(void) { LBI(0,3); }
INLINE void lbi0_4(void) { LBI(0,4); }
INLINE void lbi0_5(void) { LBI(0,5); }
INLINE void lbi0_6(void) { LBI(0,6); }
INLINE void lbi0_7(void) { LBI(0,7); }
INLINE void lbi0_8(void) { LBI(0,8); }
INLINE void lbi0_9(void) { LBI(0,9); }
INLINE void lbi0_10(void) { LBI(0,10); }
INLINE void lbi0_11(void) { LBI(0,11); }
INLINE void lbi0_12(void) { LBI(0,12); }
INLINE void lbi0_13(void) { LBI(0,13); }
INLINE void lbi0_14(void) { LBI(0,14); }
INLINE void lbi0_15(void) { LBI(0,15); }
INLINE void lbi1_0(void) { LBI(1,0); }
INLINE void lbi1_1(void) { LBI(1,1); }
INLINE void lbi1_2(void) { LBI(1,2); }
INLINE void lbi1_3(void) { LBI(1,3); }
INLINE void lbi1_4(void) { LBI(1,4); }
INLINE void lbi1_5(void) { LBI(1,5); }
INLINE void lbi1_6(void) { LBI(1,6); }
INLINE void lbi1_7(void) { LBI(1,7); }
INLINE void lbi1_8(void) { LBI(1,8); }
INLINE void lbi1_9(void) { LBI(1,9); }
INLINE void lbi1_10(void) { LBI(1,10); }
INLINE void lbi1_11(void) { LBI(1,11); }
INLINE void lbi1_12(void) { LBI(1,12); }
INLINE void lbi1_13(void) { LBI(1,13); }
INLINE void lbi1_14(void) { LBI(1,14); }
INLINE void lbi1_15(void) { LBI(1,15); }
INLINE void lbi2_0(void) { LBI(2,0); }
INLINE void lbi2_1(void) { LBI(2,1); }
INLINE void lbi2_2(void) { LBI(2,2); }
INLINE void lbi2_3(void) { LBI(2,3); }
INLINE void lbi2_4(void) { LBI(2,4); }
INLINE void lbi2_5(void) { LBI(2,5); }
INLINE void lbi2_6(void) { LBI(2,6); }
INLINE void lbi2_7(void) { LBI(2,7); }
INLINE void lbi2_8(void) { LBI(2,8); }
INLINE void lbi2_9(void) { LBI(2,9); }
INLINE void lbi2_10(void) { LBI(2,10); }
INLINE void lbi2_11(void) { LBI(2,11); }
INLINE void lbi2_12(void) { LBI(2,12); }
INLINE void lbi2_13(void) { LBI(2,13); }
INLINE void lbi2_14(void) { LBI(2,14); }
INLINE void lbi2_15(void) { LBI(2,15); }
INLINE void lbi3_0(void) { LBI(3,0); }
INLINE void lbi3_1(void) { LBI(3,1); }
INLINE void lbi3_2(void) { LBI(3,2); }
INLINE void lbi3_3(void) { LBI(3,3); }
INLINE void lbi3_4(void) { LBI(3,4); }
INLINE void lbi3_5(void) { LBI(3,5); }
INLINE void lbi3_6(void) { LBI(3,6); }
INLINE void lbi3_7(void) { LBI(3,7); }
INLINE void lbi3_8(void) { LBI(3,8); }
INLINE void lbi3_9(void) { LBI(3,9); }
INLINE void lbi3_10(void) { LBI(3,10); }
INLINE void lbi3_11(void) { LBI(3,11); }
INLINE void lbi3_12(void) { LBI(3,12); }
INLINE void lbi3_13(void) { LBI(3,13); }
INLINE void lbi3_14(void) { LBI(3,14); }
INLINE void lbi3_15(void) { LBI(3,15); }
INLINE void LEI(UINT8 y)
{
EN = y & 0x0f;
WRITE_Q(Q);
}
INLINE void lei0(void) { LEI(0); }
INLINE void lei1(void) { LEI(1); }
INLINE void lei2(void) { LEI(2); }
INLINE void lei3(void) { LEI(3); }
INLINE void lei4(void) { LEI(4); }
INLINE void lei5(void) { LEI(5); }
INLINE void lei6(void) { LEI(6); }
INLINE void lei7(void) { LEI(7); }
INLINE void lei8(void) { LEI(8); }
INLINE void lei9(void) { LEI(9); }
INLINE void lei10(void) { LEI(10); }
INLINE void lei11(void) { LEI(11); }
INLINE void lei12(void) { LEI(12); }
INLINE void lei13(void) { LEI(13); }
INLINE void lei14(void) { LEI(14); }
INLINE void lei15(void) { LEI(15); }
INLINE void lqid(void)
{
PUSH(PC + 1);
PC = (UINT16)((PC & 0x300) | (A << 4) | READ_M);
WRITE_Q(ROM(PC));
POP();
}
INLINE void nop(void) { }
INLINE void obd(void) { OUT_D(B); }
INLINE void omg(void) { WRITE_G(RAM_R(B)); }
INLINE void rc(void) { C = 0; }
INLINE void ret(void) { POP(); }
INLINE void retsk(void) { POP(); skip = 1; }
INLINE void rmb0(void) { RAM_W(B, RAM_R(B) & 0xE); }
INLINE void rmb1(void) { RAM_W(B, RAM_R(B) & 0xD); }
INLINE void rmb2(void) { RAM_W(B, RAM_R(B) & 0xB); }
INLINE void rmb3(void) { RAM_W(B, RAM_R(B) & 0x7); }
INLINE void sc(void) { C = 1; }
INLINE void skc(void) { if (C == 1) skip = 1; }
INLINE void ske(void) { if (A == RAM_R(B)) skip = 1; }
INLINE void skmbz0(void) { if ((RAM_R(B) & 0x01) == 0 ) skip = 1; }
INLINE void skmbz1(void) { if ((RAM_R(B) & 0x02) == 0 ) skip = 1; }
INLINE void skmbz2(void) { if ((RAM_R(B) & 0x04) == 0 ) skip = 1; }
INLINE void skmbz3(void) { if ((RAM_R(B) & 0x08) == 0 ) skip = 1; }
INLINE void skgbz0(void) { if ((IN_G() & 0x01) == 0) skip = 1; }
INLINE void skgbz1(void) { if ((IN_G() & 0x02) == 0) skip = 1; }
INLINE void skgbz2(void) { if ((IN_G() & 0x04) == 0) skip = 1; }
INLINE void skgbz3(void) { if ((IN_G() & 0x08) == 0) skip = 1; }
INLINE void skgz(void) { if (IN_G() == 0) skip = 1; }
INLINE void smb0(void) { RAM_W(B, RAM_R(B) | 0x1); }
INLINE void smb1(void) { RAM_W(B, RAM_R(B) | 0x2); }
INLINE void smb2(void) { RAM_W(B, RAM_R(B) | 0x4); }
INLINE void smb3(void) { RAM_W(B, RAM_R(B) | 0x8); }
INLINE void STII(UINT8 y)
{
UINT16 Bd;
RAM_W(B, y);
Bd = (B & 0x0f) + 1;
if (Bd > 15) Bd = 0;
B = (B & 0x30) + Bd;
}
INLINE void stii0(void) { STII(0x0); }
INLINE void stii1(void) { STII(0x1); }
INLINE void stii2(void) { STII(0x2); }
INLINE void stii3(void) { STII(0x3); }
INLINE void stii4(void) { STII(0x4); }
INLINE void stii5(void) { STII(0x5); }
INLINE void stii6(void) { STII(0x6); }
INLINE void stii7(void) { STII(0x7); }
INLINE void stii8(void) { STII(0x8); }
INLINE void stii9(void) { STII(0x9); }
INLINE void stii10(void) { STII(0xA); }
INLINE void stii11(void) { STII(0xB); }
INLINE void stii12(void) { STII(0xC); }
INLINE void stii13(void) { STII(0xD); }
INLINE void stii14(void) { STII(0xE); }
INLINE void stii15(void) { STII(0xF); }
INLINE void X(UINT8 r)
{
UINT8 t = RAM_R(B);
RAM_W(B, A);
A = t;
B = B ^ (r << 4);
}
INLINE void x0(void) { X(0); }
INLINE void x1(void) { X(1); }
INLINE void x2(void) { X(2); }
INLINE void x3(void) { X(3); }
INLINE void xad(void)
{
UINT8 addr = ROM(PC++) & 0x3f;
UINT8 t = A;
A = RAM_R(addr);
RAM_W(addr, t);
}
INLINE void xas(void)
{
UINT8 t = SIO;
SIO = A;
A = t;
WRITE_SK(C);
}
INLINE void XDS(UINT8 r)
{
UINT8 t, Bd, Br;
t = RAM_R(B);
RAM_W(B, A);
A = t;
Br = (UINT8)((B & 0x30) ^ (r << 4));
Bd = (UINT8)((B & 0x0F) - 1);
B = (UINT8)(Br | (Bd & 0x0F));
if (Bd == 0xFF) skip = 1;
}
INLINE void XIS(UINT8 r)
{
UINT8 t, Bd, Br;
t = RAM_R(B);
RAM_W(B, A);
A = t;
Br = (UINT8)((B & 0x30) ^ (r << 4));
Bd = (UINT8)((B & 0x0F) + 1);
B = (UINT8)(Br | (Bd & 0x0F));
if (Bd == 0x10) skip = 1;
}
INLINE void xis0(void) { XIS(0); }
INLINE void xis1(void) { XIS(1); }
INLINE void xis2(void) { XIS(2); }
INLINE void xis3(void) { XIS(3); }
INLINE void xds0(void) { XDS(0); }
INLINE void xds1(void) { XDS(1); }
INLINE void xds2(void) { XDS(2); }
INLINE void xds3(void) { XDS(3); }
INLINE void xor(void) { A = RAM_R(B) ^ A; }
| /**************************************************************************
* National Semiconductor COP410 Emulator *
* *
* Copyright (C) 2006 MAME Team *
**************************************************************************/
#define ROM(VAR_0) cpu_readop(A)
#define RAM_W(VAR_0,V) (data_write_byte_8(A,V))
#define RAM_R(VAR_0) (data_read_byte_8(A))
#define IN(VAR_0) io_read_byte_8(A)
#define OUT(VAR_0,V) io_write_byte_8(A,V)
#define VAR_0 R.A
#define B R.B
#define C R.C
#define G R.G
#define VAR_1 R.Q
#define EN R.EN
#define VAR_2 R.SA
#define SB R.SB
#define VAR_3 R.SIO
#define SKL R.SKL
#define PC R.PC
#define prevPC R.PREVPC
#define skip R.skip
#define VAR_4 R.skipLBI
#define READ_M RAM_R(B)
#define FUNC_0(VAL) RAM_W(B,VAL)
#define IN_G() IN(COP400_PORT_G)
#define FUNC_1() IN(COP400_PORT_L)
#define OUT_G(VAR_0) OUT(COP400_PORT_G, (A) & R.G_mask)
#define OUT_L(VAR_0) OUT(COP400_PORT_L, (A))
#define FUNC_2(VAR_0) OUT(COP400_PORT_D, (A) & R.D_mask)
#define FUNC_3(VAR_0) OUT(COP400_PORT_SK,A)
#ifndef VAR_5
#define FUNC_4(VAR_6) { SB = SA; SA = addr; }
#define POP() { PC = SA; SA = SB; }
#endif
CLASS_0 void FUNC_5(void)
{
logerror("ICOP400: PC = %04x, Illegal opcode = %02x\n", PC-1, ROM(PC-1));
}
CLASS_0 void FUNC_6(UINT8 data)
{
SKL = data;
if (EN & 0x01)
{
FUNC_3(SKL);
}
else
{
// NOT IMPLEMENTED
FUNC_3(SKL);
}
}
CLASS_0 void WRITE_Q(UINT8 data)
{
VAR_1 = data;
if (EN & 0x04)
{
OUT_L(VAR_1);
}
}
CLASS_0 void WRITE_G(UINT8 data)
{
G = data;
OUT_G(G);
}
CLASS_0 void add(void) { VAR_0 = (VAR_0 + RAM_R(B)) & 0x0F; }
CLASS_0 void asc(void)
{
VAR_0 = VAR_0 + C + RAM_R(B);
if (VAR_0 > 0xF)
{
C = 1;
skip = 1;
VAR_0 &= 0xF;
}
else
{
C = 0;
}
}
CLASS_0 void AISC(int y)
{
VAR_0 = VAR_0 + y;
if (VAR_0 > 0xF)
{
skip = 1;
VAR_0 &= 0xF;
}
}
CLASS_0 void aisc1(void) { AISC(0x1); }
CLASS_0 void FUNC_7(void) { AISC(0x2); }
CLASS_0 void FUNC_8(void) { AISC(0x3); }
CLASS_0 void aisc4(void) { AISC(0x4); }
CLASS_0 void FUNC_9(void) { AISC(0x5); }
CLASS_0 void aisc6(void) { AISC(0x6); }
CLASS_0 void aisc7(void) { AISC(0x7); }
CLASS_0 void aisc8(void) { AISC(0x8); }
CLASS_0 void aisc9(void) { AISC(0x9); }
CLASS_0 void aisc10(void) { AISC(0xA); }
CLASS_0 void aisc11(void) { AISC(0xB); }
CLASS_0 void FUNC_10(void) { AISC(0xC); }
CLASS_0 void aisc13(void) { AISC(0xD); }
CLASS_0 void aisc14(void) { AISC(0xE); }
CLASS_0 void aisc15(void) { AISC(0xF); }
CLASS_0 void FUNC_11(void) { B = (B & 0x30) | VAR_0; }
CLASS_0 void camq(void) { WRITE_Q((VAR_0 << 4) | READ_M); }
CLASS_0 void FUNC_12(void) { VAR_0 = B & 0xF; }
CLASS_0 void FUNC_13(void){ VAR_0 = 0; }
CLASS_0 void FUNC_14(void) { VAR_0 = VAR_0 ^ 0xF; }
CLASS_0 void ing(void) { VAR_0 = IN_G(); }
CLASS_0 void inl(void)
{
UINT8 L = FUNC_1();
RAM_W(B, L >> 4);
VAR_0 = L & 0xF;
}
CLASS_0 void jid(void)
{
UINT16 VAR_6 = (PC & 0x300) | (VAR_0 << 4) | READ_M;
PC = (PC & 0x300) | ROM(VAR_6);
}
CLASS_0 void JMP(UINT8 a8)
{
PC = (a8 << 8) | ROM(PC);
}
CLASS_0 void jmp0(void) { JMP(0); }
CLASS_0 void jmp1(void) { JMP(1); }
CLASS_0 void jmp2(void) { JMP(2); }
CLASS_0 void jmp3(void) { JMP(3); }
CLASS_0 void FUNC_15(void)
{
UINT8 op = ROM(prevPC);
if (((PC & 0x3E0) >= 0x80) && ((PC & 0x3E0) < 0x100)) //JP pages 2,3
{
PC = (UINT16)((PC & 0x380) | (op & 0x7F));
}
else
{
if ((op & 0xC0) == 0xC0) //JP other pages
{
PC = (UINT16)((PC & 0x3C0) | (op & 0x3F));
}
else //JSRP
{
FUNC_4((UINT16)(PC));
PC = (UINT16)(0x80 | (op & 0x3F));
}
}
}
CLASS_0 void JSR(UINT8 a8)
{
FUNC_4(PC + 1);
PC = (a8 << 8) | ROM(PC);
}
CLASS_0 void FUNC_16(void) { JSR(0); }
CLASS_0 void FUNC_17(void) { JSR(1); }
CLASS_0 void jsr2(void) { JSR(2); }
CLASS_0 void jsr3(void) { JSR(3); }
CLASS_0 void LD(UINT8 r)
{
VAR_0 = RAM_R(B);
B = B ^ (r << 4);
}
CLASS_0 void FUNC_18(void) { LD(0); }
CLASS_0 void FUNC_19(void) { LD(1); }
CLASS_0 void ld2(void) { LD(2); }
CLASS_0 void ld3(void) { LD(3); }
CLASS_0 void LBI(UINT8 r, UINT8 d)
{
B = (r << 4) | d;
VAR_4 = 1;
}
CLASS_0 void FUNC_20(void) { LBI(0,0); }
CLASS_0 void lbi0_1(void) { LBI(0,1); }
CLASS_0 void lbi0_2(void) { LBI(0,2); }
CLASS_0 void lbi0_3(void) { LBI(0,3); }
CLASS_0 void lbi0_4(void) { LBI(0,4); }
CLASS_0 void FUNC_21(void) { LBI(0,5); }
CLASS_0 void lbi0_6(void) { LBI(0,6); }
CLASS_0 void FUNC_22(void) { LBI(0,7); }
CLASS_0 void FUNC_23(void) { LBI(0,8); }
CLASS_0 void lbi0_9(void) { LBI(0,9); }
CLASS_0 void lbi0_10(void) { LBI(0,10); }
CLASS_0 void FUNC_24(void) { LBI(0,11); }
CLASS_0 void lbi0_12(void) { LBI(0,12); }
CLASS_0 void FUNC_25(void) { LBI(0,13); }
CLASS_0 void lbi0_14(void) { LBI(0,14); }
CLASS_0 void lbi0_15(void) { LBI(0,15); }
CLASS_0 void lbi1_0(void) { LBI(1,0); }
CLASS_0 void FUNC_26(void) { LBI(1,1); }
CLASS_0 void FUNC_27(void) { LBI(1,2); }
CLASS_0 void FUNC_28(void) { LBI(1,3); }
CLASS_0 void FUNC_29(void) { LBI(1,4); }
CLASS_0 void lbi1_5(void) { LBI(1,5); }
CLASS_0 void FUNC_30(void) { LBI(1,6); }
CLASS_0 void FUNC_31(void) { LBI(1,7); }
CLASS_0 void FUNC_32(void) { LBI(1,8); }
CLASS_0 void lbi1_9(void) { LBI(1,9); }
CLASS_0 void lbi1_10(void) { LBI(1,10); }
CLASS_0 void FUNC_33(void) { LBI(1,11); }
CLASS_0 void lbi1_12(void) { LBI(1,12); }
CLASS_0 void lbi1_13(void) { LBI(1,13); }
CLASS_0 void FUNC_34(void) { LBI(1,14); }
CLASS_0 void lbi1_15(void) { LBI(1,15); }
CLASS_0 void lbi2_0(void) { LBI(2,0); }
CLASS_0 void lbi2_1(void) { LBI(2,1); }
CLASS_0 void FUNC_35(void) { LBI(2,2); }
CLASS_0 void lbi2_3(void) { LBI(2,3); }
CLASS_0 void FUNC_36(void) { LBI(2,4); }
CLASS_0 void lbi2_5(void) { LBI(2,5); }
CLASS_0 void lbi2_6(void) { LBI(2,6); }
CLASS_0 void lbi2_7(void) { LBI(2,7); }
CLASS_0 void lbi2_8(void) { LBI(2,8); }
CLASS_0 void FUNC_37(void) { LBI(2,9); }
CLASS_0 void lbi2_10(void) { LBI(2,10); }
CLASS_0 void lbi2_11(void) { LBI(2,11); }
CLASS_0 void FUNC_38(void) { LBI(2,12); }
CLASS_0 void lbi2_13(void) { LBI(2,13); }
CLASS_0 void lbi2_14(void) { LBI(2,14); }
CLASS_0 void lbi2_15(void) { LBI(2,15); }
CLASS_0 void lbi3_0(void) { LBI(3,0); }
CLASS_0 void lbi3_1(void) { LBI(3,1); }
CLASS_0 void FUNC_39(void) { LBI(3,2); }
CLASS_0 void lbi3_3(void) { LBI(3,3); }
CLASS_0 void lbi3_4(void) { LBI(3,4); }
CLASS_0 void lbi3_5(void) { LBI(3,5); }
CLASS_0 void lbi3_6(void) { LBI(3,6); }
CLASS_0 void lbi3_7(void) { LBI(3,7); }
CLASS_0 void FUNC_40(void) { LBI(3,8); }
CLASS_0 void FUNC_41(void) { LBI(3,9); }
CLASS_0 void FUNC_42(void) { LBI(3,10); }
CLASS_0 void FUNC_43(void) { LBI(3,11); }
CLASS_0 void lbi3_12(void) { LBI(3,12); }
CLASS_0 void FUNC_44(void) { LBI(3,13); }
CLASS_0 void FUNC_45(void) { LBI(3,14); }
CLASS_0 void lbi3_15(void) { LBI(3,15); }
CLASS_0 void LEI(UINT8 y)
{
EN = y & 0x0f;
WRITE_Q(VAR_1);
}
CLASS_0 void lei0(void) { LEI(0); }
CLASS_0 void FUNC_46(void) { LEI(1); }
CLASS_0 void lei2(void) { LEI(2); }
CLASS_0 void lei3(void) { LEI(3); }
CLASS_0 void lei4(void) { LEI(4); }
CLASS_0 void lei5(void) { LEI(5); }
CLASS_0 void lei6(void) { LEI(6); }
CLASS_0 void FUNC_47(void) { LEI(7); }
CLASS_0 void FUNC_48(void) { LEI(8); }
CLASS_0 void lei9(void) { LEI(9); }
CLASS_0 void FUNC_49(void) { LEI(10); }
CLASS_0 void lei11(void) { LEI(11); }
CLASS_0 void lei12(void) { LEI(12); }
CLASS_0 void FUNC_50(void) { LEI(13); }
CLASS_0 void FUNC_51(void) { LEI(14); }
CLASS_0 void lei15(void) { LEI(15); }
CLASS_0 void lqid(void)
{
FUNC_4(PC + 1);
PC = (UINT16)((PC & 0x300) | (VAR_0 << 4) | READ_M);
WRITE_Q(ROM(PC));
POP();
}
CLASS_0 void nop(void) { }
CLASS_0 void FUNC_52(void) { FUNC_2(B); }
CLASS_0 void omg(void) { WRITE_G(RAM_R(B)); }
CLASS_0 void FUNC_53(void) { C = 0; }
CLASS_0 void ret(void) { POP(); }
CLASS_0 void retsk(void) { POP(); skip = 1; }
CLASS_0 void FUNC_54(void) { RAM_W(B, RAM_R(B) & 0xE); }
CLASS_0 void rmb1(void) { RAM_W(B, RAM_R(B) & 0xD); }
CLASS_0 void rmb2(void) { RAM_W(B, RAM_R(B) & 0xB); }
CLASS_0 void rmb3(void) { RAM_W(B, RAM_R(B) & 0x7); }
CLASS_0 void sc(void) { C = 1; }
CLASS_0 void skc(void) { if (C == 1) skip = 1; }
CLASS_0 void ske(void) { if (VAR_0 == RAM_R(B)) skip = 1; }
CLASS_0 void skmbz0(void) { if ((RAM_R(B) & 0x01) == 0 ) skip = 1; }
CLASS_0 void FUNC_55(void) { if ((RAM_R(B) & 0x02) == 0 ) skip = 1; }
CLASS_0 void skmbz2(void) { if ((RAM_R(B) & 0x04) == 0 ) skip = 1; }
CLASS_0 void FUNC_56(void) { if ((RAM_R(B) & 0x08) == 0 ) skip = 1; }
CLASS_0 void skgbz0(void) { if ((IN_G() & 0x01) == 0) skip = 1; }
CLASS_0 void skgbz1(void) { if ((IN_G() & 0x02) == 0) skip = 1; }
CLASS_0 void skgbz2(void) { if ((IN_G() & 0x04) == 0) skip = 1; }
CLASS_0 void skgbz3(void) { if ((IN_G() & 0x08) == 0) skip = 1; }
CLASS_0 void FUNC_57(void) { if (IN_G() == 0) skip = 1; }
CLASS_0 void smb0(void) { RAM_W(B, RAM_R(B) | 0x1); }
CLASS_0 void FUNC_58(void) { RAM_W(B, RAM_R(B) | 0x2); }
CLASS_0 void smb2(void) { RAM_W(B, RAM_R(B) | 0x4); }
CLASS_0 void smb3(void) { RAM_W(B, RAM_R(B) | 0x8); }
CLASS_0 void STII(UINT8 y)
{
UINT16 Bd;
RAM_W(B, y);
Bd = (B & 0x0f) + 1;
if (Bd > 15) Bd = 0;
B = (B & 0x30) + Bd;
}
CLASS_0 void FUNC_59(void) { STII(0x0); }
CLASS_0 void FUNC_60(void) { STII(0x1); }
CLASS_0 void stii2(void) { STII(0x2); }
CLASS_0 void stii3(void) { STII(0x3); }
CLASS_0 void FUNC_61(void) { STII(0x4); }
CLASS_0 void FUNC_62(void) { STII(0x5); }
CLASS_0 void stii6(void) { STII(0x6); }
CLASS_0 void stii7(void) { STII(0x7); }
CLASS_0 void stii8(void) { STII(0x8); }
CLASS_0 void FUNC_63(void) { STII(0x9); }
CLASS_0 void stii10(void) { STII(0xA); }
CLASS_0 void FUNC_64(void) { STII(0xB); }
CLASS_0 void stii12(void) { STII(0xC); }
CLASS_0 void FUNC_65(void) { STII(0xD); }
CLASS_0 void stii14(void) { STII(0xE); }
CLASS_0 void FUNC_66(void) { STII(0xF); }
CLASS_0 void X(UINT8 r)
{
UINT8 VAR_7 = RAM_R(B);
RAM_W(B, VAR_0);
VAR_0 = VAR_7;
B = B ^ (r << 4);
}
CLASS_0 void x0(void) { X(0); }
CLASS_0 void x1(void) { X(1); }
CLASS_0 void x2(void) { X(2); }
CLASS_0 void x3(void) { X(3); }
CLASS_0 void xad(void)
{
UINT8 VAR_6 = ROM(PC++) & 0x3f;
UINT8 VAR_7 = VAR_0;
VAR_0 = RAM_R(VAR_6);
RAM_W(VAR_6, VAR_7);
}
CLASS_0 void xas(void)
{
UINT8 VAR_7 = VAR_3;
VAR_3 = VAR_0;
VAR_0 = VAR_7;
FUNC_6(C);
}
CLASS_0 void XDS(UINT8 r)
{
UINT8 VAR_7, Bd, Br;
VAR_7 = RAM_R(B);
RAM_W(B, VAR_0);
VAR_0 = VAR_7;
Br = (UINT8)((B & 0x30) ^ (r << 4));
Bd = (UINT8)((B & 0x0F) - 1);
B = (UINT8)(Br | (Bd & 0x0F));
if (Bd == 0xFF) skip = 1;
}
CLASS_0 void XIS(UINT8 r)
{
UINT8 VAR_7, Bd, Br;
VAR_7 = RAM_R(B);
RAM_W(B, VAR_0);
VAR_0 = VAR_7;
Br = (UINT8)((B & 0x30) ^ (r << 4));
Bd = (UINT8)((B & 0x0F) + 1);
B = (UINT8)(Br | (Bd & 0x0F));
if (Bd == 0x10) skip = 1;
}
CLASS_0 void xis0(void) { XIS(0); }
CLASS_0 void FUNC_67(void) { XIS(1); }
CLASS_0 void FUNC_68(void) { XIS(2); }
CLASS_0 void xis3(void) { XIS(3); }
CLASS_0 void FUNC_69(void) { XDS(0); }
CLASS_0 void xds1(void) { XDS(1); }
CLASS_0 void FUNC_70(void) { XDS(2); }
CLASS_0 void FUNC_71(void) { XDS(3); }
CLASS_0 void FUNC_72(void) { VAR_0 = RAM_R(B) ^ VAR_0; }
| 0.306933 | {'VAR_0': 'A', 'VAR_1': 'Q', 'VAR_2': 'SA', 'VAR_3': 'SIO', 'VAR_4': 'skipLBI', 'FUNC_0': 'WRITE_M', 'FUNC_1': 'IN_L', 'FUNC_2': 'OUT_D', 'FUNC_3': 'OUT_SK', 'VAR_5': 'PUSH', 'FUNC_4': 'PUSH', 'VAR_6': 'addr', 'CLASS_0': 'INLINE', 'FUNC_5': 'illegal', 'FUNC_6': 'WRITE_SK', 'FUNC_7': 'aisc2', 'FUNC_8': 'aisc3', 'FUNC_9': 'aisc5', 'FUNC_10': 'aisc12', 'FUNC_11': 'cab', 'FUNC_12': 'cba', 'FUNC_13': 'clra', 'FUNC_14': 'comp', 'FUNC_15': 'jp', 'FUNC_16': 'jsr0', 'FUNC_17': 'jsr1', 'FUNC_18': 'ld0', 'FUNC_19': 'ld1', 'FUNC_20': 'lbi0_0', 'FUNC_21': 'lbi0_5', 'FUNC_22': 'lbi0_7', 'FUNC_23': 'lbi0_8', 'FUNC_24': 'lbi0_11', 'FUNC_25': 'lbi0_13', 'FUNC_26': 'lbi1_1', 'FUNC_27': 'lbi1_2', 'FUNC_28': 'lbi1_3', 'FUNC_29': 'lbi1_4', 'FUNC_30': 'lbi1_6', 'FUNC_31': 'lbi1_7', 'FUNC_32': 'lbi1_8', 'FUNC_33': 'lbi1_11', 'FUNC_34': 'lbi1_14', 'FUNC_35': 'lbi2_2', 'FUNC_36': 'lbi2_4', 'FUNC_37': 'lbi2_9', 'FUNC_38': 'lbi2_12', 'FUNC_39': 'lbi3_2', 'FUNC_40': 'lbi3_8', 'FUNC_41': 'lbi3_9', 'FUNC_42': 'lbi3_10', 'FUNC_43': 'lbi3_11', 'FUNC_44': 'lbi3_13', 'FUNC_45': 'lbi3_14', 'FUNC_46': 'lei1', 'FUNC_47': 'lei7', 'FUNC_48': 'lei8', 'FUNC_49': 'lei10', 'FUNC_50': 'lei13', 'FUNC_51': 'lei14', 'FUNC_52': 'obd', 'FUNC_53': 'rc', 'FUNC_54': 'rmb0', 'FUNC_55': 'skmbz1', 'FUNC_56': 'skmbz3', 'FUNC_57': 'skgz', 'FUNC_58': 'smb1', 'FUNC_59': 'stii0', 'FUNC_60': 'stii1', 'FUNC_61': 'stii4', 'FUNC_62': 'stii5', 'FUNC_63': 'stii9', 'FUNC_64': 'stii11', 'FUNC_65': 'stii13', 'FUNC_66': 'stii15', 'VAR_7': 't', 'FUNC_67': 'xis1', 'FUNC_68': 'xis2', 'FUNC_69': 'xds0', 'FUNC_70': 'xds2', 'FUNC_71': 'xds3', 'FUNC_72': 'xor'} |
/*
* EDAC PCI component
*
* Author: Dave Jiang <djiang@mvista.com>
*
* 2007 (c) MontaVista Software, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*
*/
#include <asm/page.h>
#include <linux/uaccess.h>
#include <linux/ctype.h>
#include <linux/highmem.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/smp.h>
#include <linux/spinlock.h>
#include <linux/sysctl.h>
#include <linux/timer.h>
#include "edac_pci.h"
#include "edac_module.h"
static DEFINE_MUTEX(edac_pci_ctls_mutex);
static LIST_HEAD(edac_pci_list);
static atomic_t pci_indexes = ATOMIC_INIT(0);
struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt,
const char *edac_pci_name)
{
struct edac_pci_ctl_info *pci;
void *p = NULL, *pvt;
unsigned int size;
edac_dbg(1, "\n");
pci = edac_align_ptr(&p, sizeof(*pci), 1);
pvt = edac_align_ptr(&p, 1, sz_pvt);
size = ((unsigned long)pvt) + sz_pvt;
/* Alloc the needed control struct memory */
pci = kzalloc(size, GFP_KERNEL);
if (pci == NULL)
return NULL;
/* Now much private space */
pvt = sz_pvt ? ((char *)pci) + ((unsigned long)pvt) : NULL;
pci->pvt_info = pvt;
pci->op_state = OP_ALLOC;
snprintf(pci->name, strlen(edac_pci_name) + 1, "%s", edac_pci_name);
return pci;
}
EXPORT_SYMBOL_GPL(edac_pci_alloc_ctl_info);
void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci)
{
edac_dbg(1, "\n");
edac_pci_remove_sysfs(pci);
}
EXPORT_SYMBOL_GPL(edac_pci_free_ctl_info);
/*
* find_edac_pci_by_dev()
* scans the edac_pci list for a specific 'struct device *'
*
* return NULL if not found, or return control struct pointer
*/
static struct edac_pci_ctl_info *find_edac_pci_by_dev(struct device *dev)
{
struct edac_pci_ctl_info *pci;
struct list_head *item;
edac_dbg(1, "\n");
list_for_each(item, &edac_pci_list) {
pci = list_entry(item, struct edac_pci_ctl_info, link);
if (pci->dev == dev)
return pci;
}
return NULL;
}
/*
* add_edac_pci_to_global_list
* Before calling this function, caller must assign a unique value to
* edac_dev->pci_idx.
* Return:
* 0 on success
* 1 on failure
*/
static int add_edac_pci_to_global_list(struct edac_pci_ctl_info *pci)
{
struct list_head *item, *insert_before;
struct edac_pci_ctl_info *rover;
edac_dbg(1, "\n");
insert_before = &edac_pci_list;
/* Determine if already on the list */
rover = find_edac_pci_by_dev(pci->dev);
if (unlikely(rover != NULL))
goto fail0;
/* Insert in ascending order by 'pci_idx', so find position */
list_for_each(item, &edac_pci_list) {
rover = list_entry(item, struct edac_pci_ctl_info, link);
if (rover->pci_idx >= pci->pci_idx) {
if (unlikely(rover->pci_idx == pci->pci_idx))
goto fail1;
insert_before = item;
break;
}
}
list_add_tail_rcu(&pci->link, insert_before);
return 0;
fail0:
edac_printk(KERN_WARNING, EDAC_PCI,
"%s (%s) %s %s already assigned %d\n",
dev_name(rover->dev), edac_dev_name(rover),
rover->mod_name, rover->ctl_name, rover->pci_idx);
return 1;
fail1:
edac_printk(KERN_WARNING, EDAC_PCI,
"but in low-level driver: attempt to assign\n"
"\tduplicate pci_idx %d in %s()\n", rover->pci_idx,
__func__);
return 1;
}
/*
* del_edac_pci_from_global_list
*
* remove the PCI control struct from the global list
*/
static void del_edac_pci_from_global_list(struct edac_pci_ctl_info *pci)
{
list_del_rcu(&pci->link);
/* these are for safe removal of devices from global list while
* NMI handlers may be traversing list
*/
synchronize_rcu();
INIT_LIST_HEAD(&pci->link);
}
/*
* edac_pci_workq_function()
*
* periodic function that performs the operation
* scheduled by a workq request, for a given PCI control struct
*/
static void edac_pci_workq_function(struct work_struct *work_req)
{
struct delayed_work *d_work = to_delayed_work(work_req);
struct edac_pci_ctl_info *pci = to_edac_pci_ctl_work(d_work);
int msec;
unsigned long delay;
edac_dbg(3, "checking\n");
mutex_lock(&edac_pci_ctls_mutex);
if (pci->op_state != OP_RUNNING_POLL) {
mutex_unlock(&edac_pci_ctls_mutex);
return;
}
if (edac_pci_get_check_errors())
pci->edac_check(pci);
/* if we are on a one second period, then use round */
msec = edac_pci_get_poll_msec();
if (msec == 1000)
delay = round_jiffies_relative(msecs_to_jiffies(msec));
else
delay = msecs_to_jiffies(msec);
edac_queue_work(&pci->work, delay);
mutex_unlock(&edac_pci_ctls_mutex);
}
int edac_pci_alloc_index(void)
{
return atomic_inc_return(&pci_indexes) - 1;
}
EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx)
{
edac_dbg(0, "\n");
pci->pci_idx = edac_idx;
pci->start_time = jiffies;
mutex_lock(&edac_pci_ctls_mutex);
if (add_edac_pci_to_global_list(pci))
goto fail0;
if (edac_pci_create_sysfs(pci)) {
edac_pci_printk(pci, KERN_WARNING,
"failed to create sysfs pci\n");
goto fail1;
}
if (pci->edac_check) {
pci->op_state = OP_RUNNING_POLL;
INIT_DELAYED_WORK(&pci->work, edac_pci_workq_function);
edac_queue_work(&pci->work, msecs_to_jiffies(edac_pci_get_poll_msec()));
} else {
pci->op_state = OP_RUNNING_INTERRUPT;
}
edac_pci_printk(pci, KERN_INFO,
"Giving out device to module %s controller %s: DEV %s (%s)\n",
pci->mod_name, pci->ctl_name, pci->dev_name,
edac_op_state_to_string(pci->op_state));
mutex_unlock(&edac_pci_ctls_mutex);
return 0;
/* error unwind stack */
fail1:
del_edac_pci_from_global_list(pci);
fail0:
mutex_unlock(&edac_pci_ctls_mutex);
return 1;
}
EXPORT_SYMBOL_GPL(edac_pci_add_device);
struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev)
{
struct edac_pci_ctl_info *pci;
edac_dbg(0, "\n");
mutex_lock(&edac_pci_ctls_mutex);
/* ensure the control struct is on the global list
* if not, then leave
*/
pci = find_edac_pci_by_dev(dev);
if (pci == NULL) {
mutex_unlock(&edac_pci_ctls_mutex);
return NULL;
}
pci->op_state = OP_OFFLINE;
del_edac_pci_from_global_list(pci);
mutex_unlock(&edac_pci_ctls_mutex);
if (pci->edac_check)
edac_stop_work(&pci->work);
edac_printk(KERN_INFO, EDAC_PCI,
"Removed device %d for %s %s: DEV %s\n",
pci->pci_idx, pci->mod_name, pci->ctl_name, edac_dev_name(pci));
return pci;
}
EXPORT_SYMBOL_GPL(edac_pci_del_device);
/*
* edac_pci_generic_check
*
* a Generic parity check API
*/
static void edac_pci_generic_check(struct edac_pci_ctl_info *pci)
{
edac_dbg(4, "\n");
edac_pci_do_parity_check();
}
/* free running instance index counter */
static int edac_pci_idx;
#define EDAC_PCI_GENCTL_NAME "EDAC PCI controller"
struct edac_pci_gen_data {
int edac_idx;
};
struct edac_pci_ctl_info *edac_pci_create_generic_ctl(struct device *dev,
const char *mod_name)
{
struct edac_pci_ctl_info *pci;
struct edac_pci_gen_data *pdata;
pci = edac_pci_alloc_ctl_info(sizeof(*pdata), EDAC_PCI_GENCTL_NAME);
if (!pci)
return NULL;
pdata = pci->pvt_info;
pci->dev = dev;
dev_set_drvdata(pci->dev, pci);
pci->dev_name = pci_name(to_pci_dev(dev));
pci->mod_name = mod_name;
pci->ctl_name = EDAC_PCI_GENCTL_NAME;
if (edac_op_state == EDAC_OPSTATE_POLL)
pci->edac_check = edac_pci_generic_check;
pdata->edac_idx = edac_pci_idx++;
if (edac_pci_add_device(pci, pdata->edac_idx) > 0) {
edac_dbg(3, "failed edac_pci_add_device()\n");
edac_pci_free_ctl_info(pci);
return NULL;
}
return pci;
}
EXPORT_SYMBOL_GPL(edac_pci_create_generic_ctl);
void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci)
{
edac_dbg(0, "pci mod=%s\n", pci->mod_name);
edac_pci_del_device(pci->dev);
edac_pci_free_ctl_info(pci);
}
EXPORT_SYMBOL_GPL(edac_pci_release_generic_ctl);
| /*
* EDAC PCI component
*
* Author: Dave Jiang <djiang@mvista.com>
*
* 2007 (c) MontaVista Software, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*
*/
#include <IMPORT_0>
#include <IMPORT_1>
#include <IMPORT_2>
#include <IMPORT_3>
#include <IMPORT_4>
#include <IMPORT_5>
#include <IMPORT_6>
#include <IMPORT_7>
#include <IMPORT_8>
#include <IMPORT_9>
#include <linux/timer.h>
#include "IMPORT_10"
#include "IMPORT_11"
static CLASS_0(VAR_0);
static CLASS_1(VAR_1);
static CLASS_2 VAR_2 = FUNC_0(0);
struct CLASS_3 *edac_pci_alloc_ctl_info(unsigned int VAR_4,
const char *VAR_5)
{
struct CLASS_3 *VAR_6;
void *VAR_7 = NULL, *pvt;
unsigned int VAR_8;
FUNC_1(1, "\n");
VAR_6 = edac_align_ptr(&VAR_7, sizeof(*VAR_6), 1);
pvt = edac_align_ptr(&VAR_7, 1, VAR_4);
VAR_8 = ((unsigned long)pvt) + VAR_4;
/* Alloc the needed control struct memory */
VAR_6 = FUNC_2(VAR_8, VAR_9);
if (VAR_6 == NULL)
return NULL;
/* Now much private space */
pvt = VAR_4 ? ((char *)VAR_6) + ((unsigned long)pvt) : NULL;
VAR_6->pvt_info = pvt;
VAR_6->VAR_10 = VAR_11;
FUNC_3(VAR_6->name, FUNC_4(VAR_5) + 1, "%s", VAR_5);
return VAR_6;
}
FUNC_5(edac_pci_alloc_ctl_info);
void FUNC_6(struct CLASS_3 *VAR_6)
{
FUNC_1(1, "\n");
FUNC_7(VAR_6);
}
FUNC_5(VAR_12);
/*
* find_edac_pci_by_dev()
* scans the edac_pci list for a specific 'struct device *'
*
* return NULL if not found, or return control struct pointer
*/
static struct CLASS_3 *find_edac_pci_by_dev(struct CLASS_4 *VAR_13)
{
struct CLASS_3 *VAR_6;
struct CLASS_5 *VAR_14;
FUNC_1(1, "\n");
FUNC_8(VAR_14, &VAR_1) {
VAR_6 = FUNC_9(VAR_14, VAR_15 VAR_3, VAR_16);
if (VAR_6->VAR_13 == VAR_13)
return VAR_6;
}
return NULL;
}
/*
* add_edac_pci_to_global_list
* Before calling this function, caller must assign a unique value to
* edac_dev->pci_idx.
* Return:
* 0 on success
* 1 on failure
*/
static int add_edac_pci_to_global_list(struct CLASS_3 *VAR_6)
{
struct CLASS_5 *VAR_14, *insert_before;
struct CLASS_3 *VAR_17;
FUNC_1(1, "\n");
insert_before = &VAR_1;
/* Determine if already on the list */
VAR_17 = find_edac_pci_by_dev(VAR_6->VAR_13);
if (FUNC_10(VAR_17 != NULL))
goto fail0;
/* Insert in ascending order by 'pci_idx', so find position */
FUNC_8(VAR_14, &VAR_1) {
VAR_17 = FUNC_9(VAR_14, VAR_15 VAR_3, VAR_16);
if (VAR_17->VAR_18 >= VAR_6->VAR_18) {
if (FUNC_10(VAR_17->VAR_18 == VAR_6->VAR_18))
goto fail1;
insert_before = VAR_14;
break;
}
}
FUNC_11(&VAR_6->VAR_16, insert_before);
return 0;
fail0:
edac_printk(VAR_19, VAR_20,
"%s (%s) %s %s already assigned %d\n",
FUNC_12(VAR_17->VAR_13), FUNC_13(VAR_17),
VAR_17->VAR_22, VAR_17->VAR_23, VAR_17->VAR_18);
return 1;
fail1:
edac_printk(VAR_19, VAR_20,
"but in low-level driver: attempt to assign\n"
"\tduplicate pci_idx %d in %s()\n", VAR_17->VAR_18,
VAR_24);
return 1;
}
/*
* del_edac_pci_from_global_list
*
* remove the PCI control struct from the global list
*/
static void FUNC_14(struct CLASS_3 *VAR_6)
{
FUNC_15(&VAR_6->VAR_16);
/* these are for safe removal of devices from global list while
* NMI handlers may be traversing list
*/
FUNC_16();
FUNC_17(&VAR_6->VAR_16);
}
/*
* edac_pci_workq_function()
*
* periodic function that performs the operation
* scheduled by a workq request, for a given PCI control struct
*/
static void FUNC_18(struct CLASS_6 *VAR_26)
{
struct CLASS_7 *VAR_27 = FUNC_19(VAR_26);
struct CLASS_3 *VAR_6 = to_edac_pci_ctl_work(VAR_27);
int VAR_28;
unsigned long VAR_29;
FUNC_1(3, "checking\n");
FUNC_20(&VAR_0);
if (VAR_6->VAR_10 != VAR_30) {
FUNC_21(&VAR_0);
return;
}
if (FUNC_22())
VAR_6->FUNC_23(VAR_6);
/* if we are on a one second period, then use round */
VAR_28 = FUNC_24();
if (VAR_28 == 1000)
VAR_29 = FUNC_25(FUNC_26(VAR_28));
else
VAR_29 = FUNC_26(VAR_28);
FUNC_27(&VAR_6->work, VAR_29);
FUNC_21(&VAR_0);
}
int FUNC_28(void)
{
return FUNC_29(&VAR_2) - 1;
}
FUNC_5(VAR_32);
int FUNC_30(struct CLASS_3 *VAR_6, int VAR_34)
{
FUNC_1(0, "\n");
VAR_6->VAR_18 = VAR_34;
VAR_6->VAR_35 = VAR_36;
FUNC_20(&VAR_0);
if (add_edac_pci_to_global_list(VAR_6))
goto fail0;
if (FUNC_31(VAR_6)) {
edac_pci_printk(VAR_6, VAR_19,
"failed to create sysfs pci\n");
goto fail1;
}
if (VAR_6->VAR_31) {
VAR_6->VAR_10 = VAR_30;
INIT_DELAYED_WORK(&VAR_6->work, VAR_25);
FUNC_27(&VAR_6->work, FUNC_26(FUNC_24()));
} else {
VAR_6->VAR_10 = OP_RUNNING_INTERRUPT;
}
edac_pci_printk(VAR_6, VAR_37,
"Giving out device to module %s controller %s: DEV %s (%s)\n",
VAR_6->VAR_22, VAR_6->VAR_23, VAR_6->VAR_21,
edac_op_state_to_string(VAR_6->VAR_10));
FUNC_21(&VAR_0);
return 0;
/* error unwind stack */
fail1:
FUNC_14(VAR_6);
fail0:
FUNC_21(&VAR_0);
return 1;
}
FUNC_5(VAR_33);
struct CLASS_3 *FUNC_32(struct CLASS_4 *VAR_13)
{
struct CLASS_3 *VAR_6;
FUNC_1(0, "\n");
FUNC_20(&VAR_0);
/* ensure the control struct is on the global list
* if not, then leave
*/
VAR_6 = find_edac_pci_by_dev(VAR_13);
if (VAR_6 == NULL) {
FUNC_21(&VAR_0);
return NULL;
}
VAR_6->VAR_10 = OP_OFFLINE;
FUNC_14(VAR_6);
FUNC_21(&VAR_0);
if (VAR_6->VAR_31)
FUNC_33(&VAR_6->work);
edac_printk(VAR_37, VAR_20,
"Removed device %d for %s %s: DEV %s\n",
VAR_6->VAR_18, VAR_6->VAR_22, VAR_6->VAR_23, FUNC_13(VAR_6));
return VAR_6;
}
FUNC_5(VAR_38);
/*
* edac_pci_generic_check
*
* a Generic parity check API
*/
static void FUNC_34(struct CLASS_3 *VAR_6)
{
FUNC_1(4, "\n");
FUNC_35();
}
/* free running instance index counter */
static int VAR_40;
#define VAR_41 "EDAC PCI controller"
struct CLASS_8 {
int VAR_34;
};
struct CLASS_3 *FUNC_36(struct CLASS_4 *VAR_13,
const char *VAR_22)
{
struct CLASS_3 *VAR_6;
struct CLASS_8 *VAR_43;
VAR_6 = edac_pci_alloc_ctl_info(sizeof(*VAR_43), VAR_41);
if (!VAR_6)
return NULL;
VAR_43 = VAR_6->pvt_info;
VAR_6->VAR_13 = VAR_13;
FUNC_37(VAR_6->VAR_13, VAR_6);
VAR_6->VAR_21 = FUNC_38(FUNC_39(VAR_13));
VAR_6->VAR_22 = VAR_22;
VAR_6->VAR_23 = VAR_41;
if (VAR_44 == VAR_45)
VAR_6->VAR_31 = VAR_39;
VAR_43->VAR_34 = VAR_40++;
if (FUNC_30(VAR_6, VAR_43->VAR_34) > 0) {
FUNC_1(3, "failed edac_pci_add_device()\n");
FUNC_6(VAR_6);
return NULL;
}
return VAR_6;
}
FUNC_5(VAR_42);
void FUNC_40(struct CLASS_3 *VAR_6)
{
FUNC_1(0, "pci mod=%s\n", VAR_6->VAR_22);
FUNC_32(VAR_6->VAR_13);
FUNC_6(VAR_6);
}
FUNC_5(VAR_46);
| 0.845143 | {'IMPORT_0': 'asm/page.h', 'IMPORT_1': 'linux/uaccess.h', 'IMPORT_2': 'linux/ctype.h', 'IMPORT_3': 'linux/highmem.h', 'IMPORT_4': 'linux/init.h', 'IMPORT_5': 'linux/module.h', 'IMPORT_6': 'linux/slab.h', 'IMPORT_7': 'linux/smp.h', 'IMPORT_8': 'linux/spinlock.h', 'IMPORT_9': 'linux/sysctl.h', 'IMPORT_10': 'edac_pci.h', 'IMPORT_11': 'edac_module.h', 'CLASS_0': 'DEFINE_MUTEX', 'VAR_0': 'edac_pci_ctls_mutex', 'CLASS_1': 'LIST_HEAD', 'VAR_1': 'edac_pci_list', 'CLASS_2': 'atomic_t', 'VAR_2': 'pci_indexes', 'FUNC_0': 'ATOMIC_INIT', 'CLASS_3': 'edac_pci_ctl_info', 'VAR_3': 'edac_pci_ctl_info', 'VAR_4': 'sz_pvt', 'VAR_5': 'edac_pci_name', 'VAR_6': 'pci', 'VAR_7': 'p', 'VAR_8': 'size', 'FUNC_1': 'edac_dbg', 'FUNC_2': 'kzalloc', 'VAR_9': 'GFP_KERNEL', 'VAR_10': 'op_state', 'VAR_11': 'OP_ALLOC', 'FUNC_3': 'snprintf', 'FUNC_4': 'strlen', 'FUNC_5': 'EXPORT_SYMBOL_GPL', 'FUNC_6': 'edac_pci_free_ctl_info', 'VAR_12': 'edac_pci_free_ctl_info', 'FUNC_7': 'edac_pci_remove_sysfs', 'CLASS_4': 'device', 'VAR_13': 'dev', 'CLASS_5': 'list_head', 'VAR_14': 'item', 'FUNC_8': 'list_for_each', 'FUNC_9': 'list_entry', 'VAR_15': 'struct', 'VAR_16': 'link', 'VAR_17': 'rover', 'FUNC_10': 'unlikely', 'VAR_18': 'pci_idx', 'FUNC_11': 'list_add_tail_rcu', 'VAR_19': 'KERN_WARNING', 'VAR_20': 'EDAC_PCI', 'FUNC_12': 'dev_name', 'VAR_21': 'dev_name', 'FUNC_13': 'edac_dev_name', 'VAR_22': 'mod_name', 'VAR_23': 'ctl_name', 'VAR_24': '__func__', 'FUNC_14': 'del_edac_pci_from_global_list', 'FUNC_15': 'list_del_rcu', 'FUNC_16': 'synchronize_rcu', 'FUNC_17': 'INIT_LIST_HEAD', 'FUNC_18': 'edac_pci_workq_function', 'VAR_25': 'edac_pci_workq_function', 'CLASS_6': 'work_struct', 'VAR_26': 'work_req', 'CLASS_7': 'delayed_work', 'VAR_27': 'd_work', 'FUNC_19': 'to_delayed_work', 'VAR_28': 'msec', 'VAR_29': 'delay', 'FUNC_20': 'mutex_lock', 'VAR_30': 'OP_RUNNING_POLL', 'FUNC_21': 'mutex_unlock', 'FUNC_22': 'edac_pci_get_check_errors', 'FUNC_23': 'edac_check', 'VAR_31': 'edac_check', 'FUNC_24': 'edac_pci_get_poll_msec', 'FUNC_25': 'round_jiffies_relative', 'FUNC_26': 'msecs_to_jiffies', 'FUNC_27': 'edac_queue_work', 'FUNC_28': 'edac_pci_alloc_index', 'VAR_32': 'edac_pci_alloc_index', 'FUNC_29': 'atomic_inc_return', 'FUNC_30': 'edac_pci_add_device', 'VAR_33': 'edac_pci_add_device', 'VAR_34': 'edac_idx', 'VAR_35': 'start_time', 'VAR_36': 'jiffies', 'FUNC_31': 'edac_pci_create_sysfs', 'VAR_37': 'KERN_INFO', 'FUNC_32': 'edac_pci_del_device', 'VAR_38': 'edac_pci_del_device', 'FUNC_33': 'edac_stop_work', 'FUNC_34': 'edac_pci_generic_check', 'VAR_39': 'edac_pci_generic_check', 'FUNC_35': 'edac_pci_do_parity_check', 'VAR_40': 'edac_pci_idx', 'VAR_41': 'EDAC_PCI_GENCTL_NAME', 'CLASS_8': 'edac_pci_gen_data', 'FUNC_36': 'edac_pci_create_generic_ctl', 'VAR_42': 'edac_pci_create_generic_ctl', 'VAR_43': 'pdata', 'FUNC_37': 'dev_set_drvdata', 'FUNC_38': 'pci_name', 'FUNC_39': 'to_pci_dev', 'VAR_44': 'edac_op_state', 'VAR_45': 'EDAC_OPSTATE_POLL', 'FUNC_40': 'edac_pci_release_generic_ctl', 'VAR_46': 'edac_pci_release_generic_ctl'} |
#include <stdint.h>
#include <stdlib.h>
#include <kernel/panic.h>
#if UINT32_MAX == UINTPTR_MAX
#define STACK_CHK_GUARD 0xe2dee396
#else
#define STACK_CHK_GUARD 0x595e9fbd94fda766
#endif
uintptr_t __stack_chk_guard = STACK_CHK_GUARD;
__attribute__((noreturn))
void __stack_chk_fail(void)
{
#if __is_libc
abort();
#elif __is_libk
panic("Stack smashing detected");
#endif
while (1) { }
__builtin_unreachable();
}
| #include <IMPORT_0>
#include <IMPORT_1>
#include <IMPORT_2>
#if VAR_0 == VAR_1
#define VAR_2 0xe2dee396
#else
#define VAR_2 0x595e9fbd94fda766
#endif
uintptr_t VAR_3 = VAR_2;
__attribute__((VAR_4))
void FUNC_0(void)
{
#if VAR_5
abort();
#elif __is_libk
FUNC_1("Stack smashing detected");
#endif
while (1) { }
FUNC_2();
}
| 0.83957 | {'IMPORT_0': 'stdint.h', 'IMPORT_1': 'stdlib.h', 'IMPORT_2': 'kernel/panic.h', 'VAR_0': 'UINT32_MAX', 'VAR_1': 'UINTPTR_MAX', 'VAR_2': 'STACK_CHK_GUARD', 'VAR_3': '__stack_chk_guard', 'VAR_4': 'noreturn', 'FUNC_0': '__stack_chk_fail', 'VAR_5': '__is_libc', 'FUNC_1': 'panic', 'FUNC_2': '__builtin_unreachable'} |
#pragma once
#include "oxygine_include.h"
#include "Vector2.h"
#include "Matrix.h"
namespace oxygine
{
template<class T>
class AffineTransformT
{
public:
typedef VectorT2<T> vector2;
typedef AffineTransformT<T> affineTransform;
typedef MatrixT<T> matrix;
AffineTransformT() {}
AffineTransformT(T a_, T b_, T c_, T d_, T x_, T y_): a(a_), b(b_), c(c_), d(d_), x(x_), y(y_) {}
explicit AffineTransformT(const matrix& m)
{
a = m.ml[0];
b = m.ml[1];
c = m.ml[4];
d = m.ml[5];
x = m.ml[12];
y = m.ml[13];
}
void identity()
{
a = T(1);
b = T(0);
c = T(0);
d = T(1);
x = T(0);
y = T(0);
}
static affineTransform getIdentity()
{
affineTransform t;
t.identity();
return t;
}
void translate(const vector2& v)
{
x += a * v.x + c * v.y;
y += b * v.x + d * v.y;
}
affineTransform translated(const vector2& v) const
{
affineTransform t = *this;
t.translate(v);
return t;
}
void scale(const vector2& v)
{
a *= v.x;
b *= v.x;
c *= v.y;
d *= v.y;
}
affineTransform scaled(const vector2& v) const
{
affineTransform t = *this;
t.scale(v);
return t;
}
void rotate(T v)
{
T sin_ = scalar::sin(v);
T cos_ = scalar::cos(v);
affineTransform rot(cos_, sin_, -sin_, cos_, 0, 0);
*this = *this * rot;
}
affineTransform rotated(T v) const
{
affineTransform t = *this;
t.rotate(v);
return t;
}
void invert()
{
affineTransform t = *this;
T det = T(1) / (t.a * t.d - t.b * t.c);
a = det * t.d;
b = -det * t.b;
c = -det * t.c;
d = det * t.a;
x = det * (t.c * t.y - t.d * t.x);
y = det * (t.b * t.x - t.a * t.y);
}
affineTransform inverted() const
{
affineTransform t = *this;
t.invert();
return t;
}
operator matrix() const
{
return toMatrix();
}
matrix toMatrix() const
{
return matrix(
a, b, 0, 0,
c, d, 0, 0,
0, 0, 1, 0,
x, y, 0, 1
);
}
static affineTransform& multiply(affineTransform& out, const affineTransform& t1, const affineTransform& t2)
{
out.a = t1.a * t2.a + t1.b * t2.c;
out.b = t1.a * t2.b + t1.b * t2.d;
out.c = t1.c * t2.a + t1.d * t2.c;
out.d = t1.c * t2.b + t1.d * t2.d;
out.x = t1.x * t2.a + t1.y * t2.c + t2.x;
out.y = t1.x * t2.b + t1.y * t2.d + t2.y;
return out;
}
affineTransform operator * (const affineTransform& t2) const
{
affineTransform r;
multiply(r, *this, t2);
return r;
}
vector2 transform(const vector2& v) const
{
return vector2(
a * v.x + c * v.y + x,
b * v.x + d * v.y + y);
}
T a, b, c, d;
T x, y;
};
typedef AffineTransformT<float> AffineTransform;
}
| #pragma once
#include "IMPORT_0"
#include "IMPORT_1"
#include "IMPORT_2"
CLASS_0 VAR_0
{
VAR_1<VAR_2 VAR_3>
VAR_2 VAR_4
{
public:
VAR_5 VAR_6<VAR_3> VAR_7;
typedef CLASS_2<CLASS_1> ID_1;
typedef CLASS_5<CLASS_1> ID_2;
FUNC_1() {}
VAR_4(ID_0 VAR_9, VAR_3 VAR_10, VAR_3 VAR_11, VAR_3 d_, VAR_3 VAR_12, VAR_3 VAR_13): FUNC_4(CLASS_7), FUNC_5(CLASS_8), FUNC_6(CLASS_9), FUNC_7(d_), FUNC_8(CLASS_10), FUNC_9(CLASS_11) {}
CLASS_12 FUNC_1(const CLASS_6& VAR_20)
{
VAR_14 = VAR_20.VAR_21[0];
VAR_15 = VAR_20.VAR_21[1];
VAR_16 = VAR_20.VAR_21[4];
VAR_17 = VAR_20.VAR_21[5];
VAR_18 = VAR_20.VAR_21[12];
VAR_19 = VAR_20.VAR_21[13];
}
void FUNC_10()
{
VAR_14 = FUNC_0(1);
VAR_15 = FUNC_0(0);
VAR_16 = FUNC_0(0);
VAR_17 = FUNC_0(1);
VAR_18 = FUNC_0(0);
VAR_19 = FUNC_0(0);
}
static CLASS_4 FUNC_11()
{
CLASS_4 VAR_22;
VAR_22.FUNC_10();
return VAR_22;
}
void translate(const CLASS_3& VAR_23)
{
VAR_18 += VAR_14 * VAR_23.VAR_18 + VAR_16 * VAR_23.VAR_19;
VAR_19 += VAR_15 * VAR_23.VAR_18 + VAR_17 * VAR_23.VAR_19;
}
CLASS_4 FUNC_12(const CLASS_3& VAR_23) VAR_24
{
CLASS_4 VAR_22 = *VAR_25;
VAR_22.translate(VAR_23);
return VAR_22;
}
void FUNC_13(const CLASS_3& VAR_23)
{
VAR_14 *= VAR_23.VAR_18;
VAR_15 *= VAR_23.VAR_18;
VAR_16 *= VAR_23.VAR_19;
VAR_17 *= VAR_23.VAR_19;
}
CLASS_4 FUNC_14(const CLASS_3& VAR_23) VAR_24
{
CLASS_4 VAR_22 = *VAR_25;
VAR_22.FUNC_13(VAR_23);
return VAR_22;
}
void FUNC_15(CLASS_1 VAR_23)
{
CLASS_1 VAR_26 = VAR_27::FUNC_16(VAR_23);
CLASS_1 VAR_28 = VAR_27::FUNC_17(VAR_23);
CLASS_4 VAR_29(VAR_28, VAR_26, -VAR_26, VAR_28, 0, 0);
*VAR_25 = *VAR_25 * VAR_29;
}
CLASS_4 FUNC_18(CLASS_1 VAR_23) VAR_24
{
CLASS_4 VAR_22 = *VAR_25;
VAR_22.FUNC_15(VAR_23);
return VAR_22;
}
void FUNC_19()
{
CLASS_4 VAR_22 = *VAR_25;
CLASS_1 VAR_30 = FUNC_0(1) / (VAR_22.VAR_14 * VAR_22.VAR_17 - VAR_22.VAR_15 * VAR_22.VAR_16);
VAR_14 = VAR_30 * VAR_22.VAR_17;
VAR_15 = -VAR_30 * VAR_22.VAR_15;
VAR_16 = -VAR_30 * VAR_22.VAR_16;
VAR_17 = VAR_30 * VAR_22.VAR_14;
VAR_18 = VAR_30 * (VAR_22.VAR_16 * VAR_22.VAR_19 - VAR_22.VAR_17 * VAR_22.VAR_18);
VAR_19 = VAR_30 * (VAR_22.VAR_15 * VAR_22.VAR_18 - VAR_22.VAR_14 * VAR_22.VAR_19);
}
CLASS_4 FUNC_20() const
{
CLASS_4 VAR_22 = *VAR_25;
VAR_22.FUNC_19();
return VAR_22;
}
operator FUNC_3() const
{
return FUNC_21();
}
CLASS_6 FUNC_21() const
{
return FUNC_3(
VAR_14, VAR_15, 0, 0,
VAR_16, VAR_17, 0, 0,
0, 0, 1, 0,
VAR_18, VAR_19, 0, 1
);
}
static CLASS_4& FUNC_22(VAR_8& VAR_31, VAR_24 VAR_8& VAR_32, VAR_24 VAR_8& VAR_33)
{
VAR_31.VAR_14 = VAR_32.VAR_14 * VAR_33.VAR_14 + VAR_32.VAR_15 * VAR_33.VAR_16;
VAR_31.VAR_15 = VAR_32.VAR_14 * VAR_33.VAR_15 + VAR_32.VAR_15 * VAR_33.VAR_17;
VAR_31.VAR_16 = VAR_32.VAR_16 * VAR_33.VAR_14 + VAR_32.VAR_17 * VAR_33.VAR_16;
VAR_31.VAR_17 = VAR_32.VAR_16 * VAR_33.VAR_15 + VAR_32.VAR_17 * VAR_33.VAR_17;
VAR_31.VAR_18 = VAR_32.VAR_18 * VAR_33.VAR_14 + VAR_32.VAR_19 * VAR_33.VAR_16 + VAR_33.VAR_18;
VAR_31.VAR_19 = VAR_32.VAR_18 * VAR_33.VAR_15 + VAR_32.VAR_19 * VAR_33.VAR_17 + VAR_33.VAR_19;
return VAR_31;
}
CLASS_4 operator * (const CLASS_4& VAR_33) VAR_24
{
CLASS_4 VAR_34;
FUNC_22(VAR_34, *VAR_25, VAR_33);
return VAR_34;
}
CLASS_3 FUNC_23(const CLASS_3& VAR_23) VAR_24
{
return FUNC_2(
VAR_14 * VAR_23.VAR_18 + VAR_16 * VAR_23.VAR_19 + VAR_18,
VAR_15 * VAR_23.VAR_18 + VAR_17 * VAR_23.VAR_19 + VAR_19);
}
CLASS_1 VAR_14, VAR_15, VAR_16, VAR_17;
CLASS_1 VAR_18, VAR_19;
};
typedef CLASS_2<float> ID_3;
}
| 0.870298 | {'IMPORT_0': 'oxygine_include.h', 'IMPORT_1': 'Vector2.h', 'IMPORT_2': 'Matrix.h', 'CLASS_0': 'namespace', 'VAR_0': 'oxygine', 'VAR_1': 'template', 'VAR_2': 'class', 'VAR_3': 'T', 'CLASS_1': 'T', 'ID_0': 'T', 'FUNC_0': 'T', 'VAR_4': 'AffineTransformT', 'CLASS_2': 'AffineTransformT', 'FUNC_1': 'AffineTransformT', 'VAR_5': 'typedef', 'VAR_6': 'VectorT2', 'VAR_7': 'vector2', 'CLASS_3': 'vector2', 'FUNC_2': 'vector2', 'ID_1': 'affineTransform', 'CLASS_4': 'affineTransform', 'VAR_8': 'affineTransform', 'CLASS_5': 'MatrixT', 'ID_2': 'matrix', 'CLASS_6': 'matrix', 'FUNC_3': 'matrix', 'VAR_9': 'a_', 'CLASS_7': 'a_', 'VAR_10': 'b_', 'CLASS_8': 'b_', 'VAR_11': 'c_', 'CLASS_9': 'c_', 'VAR_12': 'x_', 'CLASS_10': 'x_', 'VAR_13': 'y_', 'CLASS_11': 'y_', 'FUNC_4': 'a', 'VAR_14': 'a', 'FUNC_5': 'b', 'VAR_15': 'b', 'FUNC_6': 'c', 'VAR_16': 'c', 'FUNC_7': 'd', 'VAR_17': 'd', 'FUNC_8': 'x', 'VAR_18': 'x', 'FUNC_9': 'y', 'VAR_19': 'y', 'CLASS_12': 'explicit', 'VAR_20': 'm', 'VAR_21': 'ml', 'FUNC_10': 'identity', 'FUNC_11': 'getIdentity', 'VAR_22': 't', 'VAR_23': 'v', 'FUNC_12': 'translated', 'VAR_24': 'const', 'VAR_25': 'this', 'FUNC_13': 'scale', 'FUNC_14': 'scaled', 'FUNC_15': 'rotate', 'VAR_26': 'sin_', 'VAR_27': 'scalar', 'FUNC_16': 'sin', 'VAR_28': 'cos_', 'FUNC_17': 'cos', 'VAR_29': 'rot', 'FUNC_18': 'rotated', 'FUNC_19': 'invert', 'VAR_30': 'det', 'FUNC_20': 'inverted', 'FUNC_21': 'toMatrix', 'FUNC_22': 'multiply', 'VAR_31': 'out', 'VAR_32': 't1', 'VAR_33': 't2', 'VAR_34': 'r', 'FUNC_23': 'transform', 'ID_3': 'AffineTransform'} |
#pragma once
#ifndef WARP_H
#define WARP_H
#include "tfxparam.h"
#include "trop.h"
#include "trasterfx.h"
//-----------------------------------------------------------------------
struct WarpParams {
int m_shrink;
double m_warperScale;
double m_intensity;
bool m_sharpen;
};
struct LPoint {
TPointD s; // Warped lattice point
TPointD d; // Original lattice point
};
struct Lattice {
int m_width; // Number of lattice columns
int m_height; // Number of lattice rows
LPoint *coords; // Grid vertex coordinates
Lattice() : coords(0) {}
~Lattice() {
if (coords) delete[] coords;
}
};
namespace // Ugly...
{
inline int myCeil(double x) {
return ((x - (int)(x)) > TConsts::epsilon ? (int)(x) + 1 : (int)(x));
}
inline TRect convert(const TRectD &r, TPointD &dp) {
TRect ri(tfloor(r.x0), tfloor(r.y0), myCeil(r.x1), myCeil(r.y1));
dp.x = r.x0 - ri.x0;
dp.y = r.y0 - ri.y0;
assert(dp.x >= 0 && dp.y >= 0);
return ri;
}
}
//---------------------------------------------------------------------------
inline double getWarpRadius(const WarpParams ¶ms) {
return 2.55 * 1.5 * 1.5 * fabs(params.m_intensity);
}
//---------------------------------------------------------------------------
inline double getWarperEnlargement(const WarpParams ¶ms) {
// It accounts for:
// * Resample factor (1 - due to triangle filtering)
// * Eventual grid smoothening (6 - as the blur radius applied after
// resampling)
// * grid interpolation (2 - for the shepard interpolant radius)
int enlargement = 3;
if (!params.m_sharpen) enlargement += 6;
return enlargement;
}
//---------------------------------------------------------------------------
void getWarpComputeRects(TRectD &outputComputeRect, TRectD &warpedComputeRect,
const TRectD &warpedBox, const TRectD &requestedRect,
const WarpParams ¶ms);
//---------------------------------------------------------------------------
//! Deals with raster tiles and invokes warper functions
void warp(TRasterP &tileRas, const TRasterP &rasIn, TRasterP &warper,
TPointD rasInPos, TPointD warperPos, const WarpParams ¶ms);
#endif
| #pragma once
#ifndef WARP_H
#define WARP_H
#include "tfxparam.h"
#include "trop.h"
#include "trasterfx.h"
//-----------------------------------------------------------------------
struct WarpParams {
int m_shrink;
double m_warperScale;
double m_intensity;
bool m_sharpen;
};
struct LPoint {
TPointD s; // Warped lattice point
TPointD d; // Original lattice point
};
struct CLASS_0 {
int m_width; // Number of lattice columns
int m_height; // Number of lattice rows
LPoint *coords; // Grid vertex coordinates
VAR_0() : coords(0) {}
~CLASS_0() {
if (coords) delete[] coords;
}
};
namespace // Ugly...
{
inline int myCeil(double x) {
return ((x - (int)(x)) > TConsts::epsilon ? (int)(x) + 1 : (int)(x));
}
inline TRect convert(const TRectD &r, TPointD &dp) {
TRect ri(tfloor(r.x0), tfloor(r.y0), myCeil(r.x1), myCeil(r.y1));
dp.x = r.x0 - ri.x0;
dp.y = r.y0 - ri.y0;
assert(dp.x >= 0 && dp.y >= 0);
return ri;
}
}
//---------------------------------------------------------------------------
inline double getWarpRadius(const WarpParams ¶ms) {
return 2.55 * 1.5 * 1.5 * fabs(params.m_intensity);
}
//---------------------------------------------------------------------------
inline double getWarperEnlargement(const WarpParams ¶ms) {
// It accounts for:
// * Resample factor (1 - due to triangle filtering)
// * Eventual grid smoothening (6 - as the blur radius applied after
// resampling)
// * grid interpolation (2 - for the shepard interpolant radius)
int enlargement = 3;
if (!params.m_sharpen) enlargement += 6;
return enlargement;
}
//---------------------------------------------------------------------------
void getWarpComputeRects(TRectD &outputComputeRect, TRectD &warpedComputeRect,
const TRectD &warpedBox, const TRectD &requestedRect,
const WarpParams ¶ms);
//---------------------------------------------------------------------------
//! Deals with raster tiles and invokes warper functions
void warp(TRasterP &tileRas, const TRasterP &rasIn, TRasterP &warper,
TPointD VAR_1, TPointD warperPos, const WarpParams ¶ms);
#endif
| 0.036415 | {'CLASS_0': 'Lattice', 'VAR_0': 'Lattice', 'VAR_1': 'rasInPos'} |
/*
* File: NothingWork.h
* Author: Chris
*
* Created on September 25, 2015, 5:15 PM
*/
#ifndef NOTHINGWORK_H
#define NOTHINGWORK_H
#include "PDBBuzzer.h"
#include "PDBCommWork.h"
// do no work
namespace pdb {
class NothingWork : public PDBWork {
public:
NothingWork() {}
void execute(PDBBuzzerPtr callerBuzzer) override {
callerBuzzer = nullptr;
/* so we don't get a compiler error */
}
};
}
#endif /* NOTHINGWORK_H */
| /*
* File: NothingWork.h
* Author: Chris
*
* Created on September 25, 2015, 5:15 PM
*/
#ifndef NOTHINGWORK_H
#define NOTHINGWORK_H
#include "PDBBuzzer.h"
#include "PDBCommWork.h"
// do no work
CLASS_0 VAR_0 {
CLASS_1 VAR_1 : public VAR_2 {
public:
FUNC_0() {}
void FUNC_1(PDBBuzzerPtr callerBuzzer) VAR_3 {
callerBuzzer = nullptr;
/* so we don't get a compiler error */
}
};
}
#endif /* NOTHINGWORK_H */
| 0.481808 | {'CLASS_0': 'namespace', 'VAR_0': 'pdb', 'CLASS_1': 'class', 'VAR_1': 'NothingWork', 'FUNC_0': 'NothingWork', 'VAR_2': 'PDBWork', 'FUNC_1': 'execute', 'VAR_3': 'override'} |
/*
* Add a measurement to the log; the data at data_seg:data/length are
* appended to the TCG_PCClientPCREventStruct
*
* Input parameters:
* pcrIndex : which PCR to extend
* event_type : type of event; specs 10.4.1
* event_id : (unused)
* data : pointer to the data (i.e., string) to be added to the log
* length : length of the data
*/
static uint32_t
tcpa_add_measurement_to_log(uint32_t pcrIndex,
uint32_t event_type,
uint32_t event_id,
const char *data_ptr,
uint32_t length)
{
uint32_t rc = 0;
struct hleei_short hleei;
struct hleeo hleeo;
uint8_t _pcpes[32+400];
struct pcpes *pcpes = (struct pcpes *)_pcpes;
uint8_t *data = (uint8_t *)data_ptr;
if (length < sizeof(_pcpes)-32) {
memset(pcpes, 0x0, 32);
pcpes->pcrindex = pcrIndex;
pcpes->eventtype = event_type;
pcpes->eventdatasize = length;
memcpy(&_pcpes[32], data, length);
hleei.ipblength = 0x18;
hleei.reserved = 0x0;
hleei.hashdataptr = (uint32_t)&_pcpes[32];
hleei.hashdatalen = length;
hleei.pcrindex = pcrIndex;
hleei.logdataptr = (uint32_t)_pcpes;
hleei.logdatalen = length + 32;
rc = HashLogExtendEvent32(&hleei,
&hleeo,
TCG_MAGIC,
0x0,
0x0);
} else {
rc = (TCG_PC_TPMERROR |
((uint32_t)TCG_GENERAL_ERROR << 16));
}
return rc;
} | /*
* Add a measurement to the log; the data at data_seg:data/length are
* appended to the TCG_PCClientPCREventStruct
*
* Input parameters:
* pcrIndex : which PCR to extend
* event_type : type of event; specs 10.4.1
* event_id : (unused)
* data : pointer to the data (i.e., string) to be added to the log
* length : length of the data
*/
static uint32_t
tcpa_add_measurement_to_log(uint32_t VAR_0,
uint32_t event_type,
uint32_t VAR_1,
const char *VAR_2,
uint32_t VAR_3)
{
uint32_t VAR_4 = 0;
struct CLASS_0 VAR_5;
struct CLASS_1 VAR_6;
uint8_t VAR_7[32+400];
struct CLASS_2 *VAR_8 = (struct CLASS_2 *)VAR_7;
uint8_t *VAR_9 = (uint8_t *)VAR_2;
if (VAR_3 < sizeof(VAR_7)-32) {
FUNC_0(VAR_8, 0x0, 32);
VAR_8->pcrindex = VAR_0;
VAR_8->VAR_10 = event_type;
VAR_8->VAR_11 = VAR_3;
FUNC_1(&VAR_7[32], VAR_9, VAR_3);
VAR_5.VAR_12 = 0x18;
VAR_5.VAR_13 = 0x0;
VAR_5.VAR_14 = (uint32_t)&VAR_7[32];
VAR_5.VAR_15 = VAR_3;
VAR_5.pcrindex = VAR_0;
VAR_5.VAR_16 = (uint32_t)VAR_7;
VAR_5.logdatalen = VAR_3 + 32;
VAR_4 = FUNC_2(&VAR_5,
&VAR_6,
TCG_MAGIC,
0x0,
0x0);
} else {
VAR_4 = (VAR_17 |
((uint32_t)VAR_18 << 16));
}
return VAR_4;
} | 0.762053 | {'VAR_0': 'pcrIndex', 'VAR_1': 'event_id', 'VAR_2': 'data_ptr', 'VAR_3': 'length', 'VAR_4': 'rc', 'CLASS_0': 'hleei_short', 'VAR_5': 'hleei', 'CLASS_1': 'hleeo', 'VAR_6': 'hleeo', 'VAR_7': '_pcpes', 'CLASS_2': 'pcpes', 'VAR_8': 'pcpes', 'VAR_9': 'data', 'FUNC_0': 'memset', 'VAR_10': 'eventtype', 'VAR_11': 'eventdatasize', 'FUNC_1': 'memcpy', 'VAR_12': 'ipblength', 'VAR_13': 'reserved', 'VAR_14': 'hashdataptr', 'VAR_15': 'hashdatalen', 'VAR_16': 'logdataptr', 'FUNC_2': 'HashLogExtendEvent32', 'VAR_17': 'TCG_PC_TPMERROR', 'VAR_18': 'TCG_GENERAL_ERROR'} |
/*
* Copyright 2014 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MONGOC_BULK_OPERATION_PRIVATE_H
#define MONGOC_BULK_OPERATION_PRIVATE_H
#include "mongoc-array-private.h"
#include "mongoc-client.h"
#include "mongoc-write-command-private.h"
BSON_BEGIN_DECLS
struct _mongoc_bulk_operation_t
{
char *database;
char *collection;
mongoc_client_t *client;
mongoc_write_concern_t *write_concern;
bool ordered;
uint32_t hint;
mongoc_array_t commands;
mongoc_write_result_t result;
};
mongoc_bulk_operation_t *_mongoc_bulk_operation_new (mongoc_client_t *client,
const char *database,
const char *collection,
uint32_t hint,
bool ordered,
const mongoc_write_concern_t *write_concern);
BSON_END_DECLS
#endif /* MONGOC_BULK_OPERATION_PRIVATE_H */
| /*
* Copyright 2014 MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MONGOC_BULK_OPERATION_PRIVATE_H
#define MONGOC_BULK_OPERATION_PRIVATE_H
#include "IMPORT_0"
#include "IMPORT_1"
#include "mongoc-write-command-private.h"
CLASS_0
VAR_0 VAR_1
{
char *VAR_2;
char *collection;
mongoc_client_t *client;
mongoc_write_concern_t *write_concern;
bool VAR_3;
uint32_t hint;
CLASS_1 VAR_4;
mongoc_write_result_t VAR_5;
};
CLASS_2 *_mongoc_bulk_operation_new (mongoc_client_t *client,
const char *VAR_2,
const char *collection,
uint32_t hint,
bool VAR_3,
const mongoc_write_concern_t *write_concern);
CLASS_3
#endif /* MONGOC_BULK_OPERATION_PRIVATE_H */
| 0.497799 | {'IMPORT_0': 'mongoc-array-private.h', 'IMPORT_1': 'mongoc-client.h', 'CLASS_0': 'BSON_BEGIN_DECLS', 'VAR_0': 'struct', 'VAR_1': '_mongoc_bulk_operation_t', 'VAR_2': 'database', 'VAR_3': 'ordered', 'CLASS_1': 'mongoc_array_t', 'VAR_4': 'commands', 'VAR_5': 'result', 'CLASS_2': 'mongoc_bulk_operation_t', 'CLASS_3': 'BSON_END_DECLS'} |
/*
Initializes all required high-level real/virtual serial port HAL drivers:
*/
void serialport_hal_init(void)
{
uart7_setup();
} | /*
Initializes all required high-level real/virtual serial port HAL drivers:
*/
void FUNC_0(void)
{
FUNC_1();
} | 0.968822 | {'FUNC_0': 'serialport_hal_init', 'FUNC_1': 'uart7_setup'} |
/* file: minmax_kernel.h */
/*******************************************************************************
* Copyright 2014 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
//++
// Declaration of template function that calculate minmax.
//--
#ifndef __MINMAX_KERNEL_H__
#define __MINMAX_KERNEL_H__
#include "algorithms/normalization/minmax.h"
#include "src/algorithms/kernel.h"
#include "data_management/data/numeric_table.h"
#include "src/threading/threading.h"
#include "src/data_management/service_numeric_table.h"
#include "src/algorithms/service_error_handling.h"
using namespace daal::services::internal;
using namespace daal::internal;
using namespace daal::data_management;
using namespace daal::services;
namespace daal
{
namespace algorithms
{
namespace normalization
{
namespace minmax
{
namespace internal
{
/**
* \brief Kernel for minmax calculation
* in case floating point type of intermediate calculations
* and method of calculations are different
*/
template <typename algorithmFPType, Method method, CpuType cpu>
class MinMaxKernel : public Kernel
{
public:
Status compute(const NumericTable & inputTable, NumericTable & resultTable, const NumericTable & minimums, const NumericTable & maximums,
const algorithmFPType lowerBound, const algorithmFPType upperBound);
protected:
Status processBlock(const NumericTable & inputTable, NumericTable & resultTable, const algorithmFPType * scale, const algorithmFPType * shift,
const size_t startRowIndex, const size_t blockSize);
static const size_t BLOCK_SIZE_NORM = 256;
};
} // namespace internal
} // namespace minmax
} // namespace normalization
} // namespace algorithms
} // namespace daal
#endif
| /* file: minmax_kernel.h */
/*******************************************************************************
* Copyright 2014 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
//++
// Declaration of template function that calculate minmax.
//--
#ifndef __MINMAX_KERNEL_H__
#define __MINMAX_KERNEL_H__
#include "IMPORT_0"
#include "src/algorithms/kernel.h"
#include "data_management/data/numeric_table.h"
#include "IMPORT_1"
#include "src/data_management/service_numeric_table.h"
#include "src/algorithms/service_error_handling.h"
using namespace daal::services::internal;
using namespace daal::internal;
using namespace daal::data_management;
using namespace daal::services;
namespace daal
{
namespace VAR_0
{
namespace normalization
{
namespace minmax
{
namespace internal
{
/**
* \brief Kernel for minmax calculation
* in case floating point type of intermediate calculations
* and method of calculations are different
*/
VAR_1 <typename VAR_2, Method VAR_3, CpuType cpu>
VAR_4 MinMaxKernel : public Kernel
{
public:
VAR_5 compute(const NumericTable & inputTable, NumericTable & resultTable, const NumericTable & minimums, const NumericTable & VAR_6,
const CLASS_0 lowerBound, const CLASS_0 upperBound);
protected:
VAR_5 processBlock(const NumericTable & inputTable, NumericTable & resultTable, const VAR_2 * scale, const VAR_2 * shift,
const size_t startRowIndex, const size_t blockSize);
static const size_t BLOCK_SIZE_NORM = 256;
};
} // namespace internal
} // namespace minmax
} // namespace normalization
} // namespace algorithms
} // namespace daal
#endif
| 0.171035 | {'IMPORT_0': 'algorithms/normalization/minmax.h', 'IMPORT_1': 'src/threading/threading.h', 'VAR_0': 'algorithms', 'VAR_1': 'template', 'VAR_2': 'algorithmFPType', 'CLASS_0': 'algorithmFPType', 'VAR_3': 'method', 'VAR_4': 'class', 'VAR_5': 'Status', 'VAR_6': 'maximums'} |
#include "emu.h"
#include "includes/galspnbl.h"
PALETTE_INIT( galspnbl )
{
int i;
/* initialize 555 RGB lookup */
for (i = 0; i < 32768; i++)
palette_set_color_rgb(machine, i + 1024, pal5bit(i >> 5), pal5bit(i >> 10), pal5bit(i >> 0));
}
/* sprite format (see also Ninja Gaiden):
*
* word bit usage
* --------+-fedcba9876543210-+----------------
* 0 | ---------------x | flip x
* | --------------x- | flip y
* | -------------x-- | enable
* | ----------xx---- | priority?
* | ---------x------ | flicker?
* 1 | xxxxxxxxxxxxxxxx | code
* 2 | --------xxxx---- | color
* | --------------xx | size: 8x8, 16x16, 32x32, 64x64
* 3 | xxxxxxxxxxxxxxxx | y position
* 4 | xxxxxxxxxxxxxxxx | x position
* 5,6,7| | unused
*/
static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority )
{
galspnbl_state *state = machine->driver_data<galspnbl_state>();
UINT16 *spriteram = state->spriteram;
int offs;
static const UINT8 layout[8][8] =
{
{0,1,4,5,16,17,20,21},
{2,3,6,7,18,19,22,23},
{8,9,12,13,24,25,28,29},
{10,11,14,15,26,27,30,31},
{32,33,36,37,48,49,52,53},
{34,35,38,39,50,51,54,55},
{40,41,44,45,56,57,60,61},
{42,43,46,47,58,59,62,63}
};
for (offs = (state->spriteram_size - 16) / 2; offs >= 0; offs -= 8)
{
int sx, sy, code, color, size, attr, flipx, flipy;
int col, row;
attr = spriteram[offs];
if ((attr & 0x0004) && ((attr & 0x0040) == 0 || (machine->primary_screen->frame_number() & 1))
// && ((attr & 0x0030) >> 4) == priority)
&& ((attr & 0x0020) >> 5) == priority)
{
code = spriteram[offs + 1];
color = spriteram[offs + 2];
size = 1 << (color & 0x0003); // 1,2,4,8
color = (color & 0x00f0) >> 4;
// sx = spriteram[offs + 4] + screenscroll;
sx = spriteram[offs + 4];
sy = spriteram[offs + 3];
flipx = attr & 0x0001;
flipy = attr & 0x0002;
for (row = 0; row < size; row++)
{
for (col = 0; col < size; col++)
{
int x = sx + 8 * (flipx ? (size - 1 - col) : col);
int y = sy + 8 * (flipy ? (size - 1 - row) : row);
drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
code + layout[row][col],
color,
flipx,flipy,
x,y,0);
}
}
}
}
}
static void draw_background( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
galspnbl_state *state = machine->driver_data<galspnbl_state>();
offs_t offs;
// int screenscroll = 4 - (state->scroll[0] & 0xff);
for (offs = 0; offs < 0x20000; offs++)
{
int y = offs >> 9;
int x = offs & 0x1ff;
*BITMAP_ADDR16(bitmap, y, x) = 1024 + (state->bgvideoram[offs] >> 1);
}
}
VIDEO_UPDATE( galspnbl )
{
galspnbl_state *state = screen->machine->driver_data<galspnbl_state>();
int offs;
draw_background(screen->machine, bitmap, cliprect);
draw_sprites(screen->machine, bitmap, cliprect, 0);
for (offs = 0; offs < 0x1000 / 2; offs++)
{
int sx, sy, code, attr, color;
code = state->videoram[offs];
attr = state->colorram[offs];
color = (attr & 0x00f0) >> 4;
sx = offs % 64;
sy = offs / 64;
/* What is this? A priority/half transparency marker? */
if (!(attr & 0x0008))
{
drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],
code,
color,
0,0,
// 16*sx + screenscroll,8*sy,
16*sx,8*sy,0);
}
}
draw_sprites(screen->machine, bitmap, cliprect, 1);
return 0;
}
| #include "emu.h"
#include "includes/galspnbl.h"
PALETTE_INIT( VAR_0 )
{
int i;
/* initialize 555 RGB lookup */
for (i = 0; i < 32768; i++)
palette_set_color_rgb(machine, i + 1024, pal5bit(i >> 5), pal5bit(i >> 10), pal5bit(i >> 0));
}
/* sprite format (see also Ninja Gaiden):
*
* word bit usage
* --------+-fedcba9876543210-+----------------
* 0 | ---------------x | flip x
* | --------------x- | flip y
* | -------------x-- | enable
* | ----------xx---- | priority?
* | ---------x------ | flicker?
* 1 | xxxxxxxxxxxxxxxx | code
* 2 | --------xxxx---- | color
* | --------------xx | size: 8x8, 16x16, 32x32, 64x64
* 3 | xxxxxxxxxxxxxxxx | y position
* 4 | xxxxxxxxxxxxxxxx | x position
* 5,6,7| | unused
*/
static void FUNC_0( CLASS_0 *machine, CLASS_1 *bitmap, const rectangle *cliprect, int priority )
{
galspnbl_state *state = machine->VAR_1<galspnbl_state>();
UINT16 *VAR_2 = state->VAR_2;
int VAR_3;
static const UINT8 VAR_4[8][8] =
{
{0,1,4,5,16,17,20,21},
{2,3,6,7,18,19,22,23},
{8,9,12,13,24,25,28,29},
{10,11,14,15,26,27,30,31},
{32,33,36,37,48,49,52,53},
{34,35,38,39,50,51,54,55},
{40,41,44,45,56,57,60,61},
{42,43,46,47,58,59,62,63}
};
for (VAR_3 = (state->VAR_5 - 16) / 2; VAR_3 >= 0; VAR_3 -= 8)
{
int VAR_6, sy, code, VAR_7, size, attr, VAR_8, flipy;
int VAR_9, row;
attr = VAR_2[VAR_3];
if ((attr & 0x0004) && ((attr & 0x0040) == 0 || (machine->VAR_10->frame_number() & 1))
// && ((attr & 0x0030) >> 4) == priority)
&& ((attr & 0x0020) >> 5) == priority)
{
code = VAR_2[VAR_3 + 1];
VAR_7 = VAR_2[VAR_3 + 2];
size = 1 << (VAR_7 & 0x0003); // 1,2,4,8
VAR_7 = (VAR_7 & 0x00f0) >> 4;
// sx = spriteram[offs + 4] + screenscroll;
VAR_6 = VAR_2[VAR_3 + 4];
sy = VAR_2[VAR_3 + 3];
VAR_8 = attr & 0x0001;
flipy = attr & 0x0002;
for (row = 0; row < size; row++)
{
for (VAR_9 = 0; VAR_9 < size; VAR_9++)
{
int x = VAR_6 + 8 * (VAR_8 ? (size - 1 - VAR_9) : VAR_9);
int y = sy + 8 * (flipy ? (size - 1 - row) : row);
drawgfx_transpen(bitmap,cliprect,machine->VAR_11[1],
code + VAR_4[row][VAR_9],
VAR_7,
VAR_8,flipy,
x,y,0);
}
}
}
}
}
static void draw_background( CLASS_0 *machine, CLASS_1 *bitmap, const rectangle *cliprect )
{
galspnbl_state *state = machine->VAR_1<galspnbl_state>();
offs_t VAR_3;
// int screenscroll = 4 - (state->scroll[0] & 0xff);
for (VAR_3 = 0; VAR_3 < 0x20000; VAR_3++)
{
int y = VAR_3 >> 9;
int x = VAR_3 & 0x1ff;
*BITMAP_ADDR16(bitmap, y, x) = 1024 + (state->bgvideoram[VAR_3] >> 1);
}
}
VIDEO_UPDATE( VAR_0 )
{
galspnbl_state *state = screen->machine->VAR_1<galspnbl_state>();
int VAR_3;
draw_background(screen->machine, bitmap, cliprect);
FUNC_0(screen->machine, bitmap, cliprect, 0);
for (VAR_3 = 0; VAR_3 < 0x1000 / 2; VAR_3++)
{
int VAR_6, sy, code, attr, VAR_7;
code = state->VAR_12[VAR_3];
attr = state->VAR_13[VAR_3];
VAR_7 = (attr & 0x00f0) >> 4;
VAR_6 = VAR_3 % 64;
sy = VAR_3 / 64;
/* What is this? A priority/half transparency marker? */
if (!(attr & 0x0008))
{
drawgfx_transpen(bitmap,cliprect,screen->machine->VAR_11[0],
code,
VAR_7,
0,0,
// 16*sx + screenscroll,8*sy,
16*VAR_6,8*sy,0);
}
}
FUNC_0(screen->machine, bitmap, cliprect, 1);
return 0;
}
| 0.363386 | {'VAR_0': 'galspnbl', 'FUNC_0': 'draw_sprites', 'CLASS_0': 'running_machine', 'CLASS_1': 'bitmap_t', 'VAR_1': 'driver_data', 'VAR_2': 'spriteram', 'VAR_3': 'offs', 'VAR_4': 'layout', 'VAR_5': 'spriteram_size', 'VAR_6': 'sx', 'VAR_7': 'color', 'VAR_8': 'flipx', 'VAR_9': 'col', 'VAR_10': 'primary_screen', 'VAR_11': 'gfx', 'VAR_12': 'videoram', 'VAR_13': 'colorram'} |
#pragma once
namespace shared
{
class TemplatedObjectFactoryWrapper;
/*
类名:TemplatedObjectFactory
功能:根据注册类型的信息创建一个TOBJFLG的实例,类型TBase应是TOBJFLG的父类
*/
template<typename TBase, typename TOBJFLG>
class TemplatedObjectFactory : public nbase::Singleton<TemplatedObjectFactory<typename TBase, typename TOBJFLG>>
{
private:
using _ParentType = nbase::Singleton<TemplatedObjectFactory<typename TBase, typename TOBJFLG>>;
using _MyType = TemplatedObjectFactory<typename TBase, typename TOBJFLG>;
friend class TemplatedObjectFactoryWrapper;
SingletonHideConstructor(_MyType);
private:
TemplatedObjectFactory() = default;
~TemplatedObjectFactory() = default;
private:
/*
创建TClass实例的方法, 存在TClass : public TBase的关系
params TClass的构造参数
返回TBase类型的指针对像
*/
template<typename TClass>
TBase* Create()
{
return dynamic_cast<TBase*>(new TClass);
}
template<typename TClass>
void AddCreateFunction(TOBJFLG flg)
{
auto it = std::find_if(crate_function_list_.begin(), crate_function_list_.end(), [&](const decltype(*crate_function_list_.begin()) & item){
return flg == item.first;
});
if (it == crate_function_list_.end())
crate_function_list_.emplace_back(std::make_pair(flg, std::bind(&TemplatedObjectFactory::Create<TClass>, this)));
}
auto CreateSharedObject(TOBJFLG flg)->std::shared_ptr<TBase>
{
auto it = std::find_if(crate_function_list_.begin(), crate_function_list_.end(), [&](const decltype(*crate_function_list_.begin()) & item){
return flg == item.first;
});
if (it != crate_function_list_.end())
return std::shared_ptr<TBase>((*it).second());
return nullptr;
}
TBase* CreateObject(TOBJFLG flg)
{
TBase* ret = nullptr;
auto it = std::find_if(crate_function_list_.begin(), crate_function_list_.end(), [&](const decltype(*crate_function_list_.begin()) & item){
return flg == item.first;
});
if (it != crate_function_list_.end())
ret = (*it).second();
return ret;
}
void CreateAllSharedObject(std::list<std::shared_ptr<TBase>>& objects)
{
for (auto it : crate_function_list_)
objects.emplace_back(std::shared_ptr<TBase>(it.second()));
}
private:
std::list<std::pair<TOBJFLG, std::function<TBase*()>>> crate_function_list_;
};
class TemplatedObjectFactoryWrapper
{
public:
//注册类型
template<typename TBase, typename TObject, typename TOBJFLG>
static void RegisteredOjbect(const TOBJFLG& flg)
{
using TDecayType = typename std::decay<TOBJFLG>::type;
if (std::is_base_of<TBase, TObject>::value)
{
TemplatedObjectFactory<TBase, TDecayType>::GetInstance()->AddCreateFunction<TObject>(flg);
}
}
//创建含引用计数的实例
template<typename TBase, typename TFLG>
static auto InstantiateSharedRegisteredOjbect(const TFLG& flag)->std::shared_ptr<TBase>
{
using TDecayType = typename std::decay<TFLG>::type;
return TemplatedObjectFactory<TBase, TDecayType>::GetInstance()->CreateSharedObject(flag);
}
//创建实例
template<typename TBase, typename TFLG>
static auto InstantiateRegisteredOjbect(const TFLG& flag)->TBase*
{
using TDecayType = typename std::decay<TFLG>::type;
return TemplatedObjectFactory<TBase, TDecayType>::GetInstance()->CreateObject(flag);
}
//创建所有已注册为 TBase 与 TFLG 为标识的的实例
template<typename TBase, typename TFLG>
static auto InstantiateAllRegisteredSharedOjbect()->std::list<std::shared_ptr<TBase>>
{
using TDecayType = typename std::decay<TFLG>::type;
std::list<std::shared_ptr<TBase>> ret;
TemplatedObjectFactory<TBase, TDecayType>::GetInstance()->CreateAllSharedObject(ret);
return ret;
}
};
}
| #pragma once
namespace VAR_0
{
CLASS_0 VAR_2;
/*
类名:TemplatedObjectFactory
功能:根据注册类型的信息创建一个TOBJFLG的实例,类型TBase应是TOBJFLG的父类
*/
VAR_3<VAR_4 TBase, VAR_4 VAR_5>
VAR_1 TemplatedObjectFactory : public VAR_7::VAR_8<VAR_6<VAR_4 TBase, VAR_4 VAR_5>>
{
private:
VAR_9 _ParentType = VAR_7::VAR_8<VAR_6<VAR_4 TBase, VAR_4 VAR_5>>;
CLASS_2 _MyType = VAR_6<VAR_4 TBase, VAR_4 VAR_5>VAR_10;
CLASS_4 VAR_1 VAR_2;
SingletonHideConstructor(_MyType);
private:
FUNC_0() = default;
~FUNC_0() = default;
private:
/*
创建TClass实例的方法, 存在TClass : public TBase的关系
params TClass的构造参数
返回TBase类型的指针对像
*/
VAR_3<VAR_4 VAR_11>
TBase* Create()
{
return VAR_12<TBase*>(VAR_13 VAR_11);
}
VAR_3<VAR_4 VAR_11>
VAR_14 FUNC_1(VAR_5 VAR_16)
{
auto CLASS_5 = std::find_if(crate_function_list_.begin(), crate_function_list_.FUNC_2(),CLASS_3 [&](const decltype(*crate_function_list_.begin()) & VAR_18){
return VAR_16 == VAR_18.first;
});
if (VAR_17 == crate_function_list_.FUNC_2())
crate_function_list_.FUNC_3(std::FUNC_4(VAR_16, std::FUNC_5(&VAR_6::Create<VAR_11>, this)));
}
auto CreateSharedObject(ID_0 VAR_16)->std::VAR_19<TBase>
{
auto CLASS_5 = std::find_if(crate_function_list_.begin(), crate_function_list_.FUNC_2(),CLASS_3 [&](const decltype(*crate_function_list_.begin()) & VAR_18){
return VAR_16 == VAR_18.first;
});
if (VAR_17 != crate_function_list_.FUNC_2())
return std::VAR_19<TBase>((*VAR_17).FUNC_6());
return nullptr;
}
TBase* FUNC_7(CLASS_1 VAR_16)
{
TBase* VAR_20 = nullptr;
auto CLASS_5 = std::find_if(crate_function_list_.begin(), crate_function_list_.FUNC_2(),CLASS_3 [&](const decltype(*crate_function_list_.begin()) & VAR_18){
return VAR_16 == VAR_18.first;
});
if (VAR_17 != crate_function_list_.FUNC_2())
VAR_20 = (*VAR_17).FUNC_6();
return VAR_20;
}
void CreateAllSharedObject(std::VAR_21<std::VAR_19<TBase>>& VAR_22)
{
for (auto CLASS_5 : crate_function_list_)
VAR_22.FUNC_3(std::VAR_19<TBase>(VAR_17.FUNC_6()));
}
private:
std::VAR_21<std::pair<VAR_5, std::VAR_23<TBase*(VAR_10)>>> crate_function_list_;
};
CLASS_0 VAR_2
{
public:
//注册类型
VAR_3<VAR_4 TBase, VAR_4 TObject, VAR_4 VAR_5>
VAR_24 void FUNC_8(const CLASS_1& VAR_16)
{
CLASS_2 VAR_25 = VAR_4 std::VAR_26<VAR_5>::type;
if (std::VAR_27<TBase, TObject>::VAR_28)
{
VAR_6<TBase, VAR_25>::FUNC_9()->VAR_15<TObject>(VAR_16);
}
}
//创建含引用计数的实例
VAR_3<VAR_4 TBase, VAR_4 VAR_29>
VAR_24 auto InstantiateSharedRegisteredOjbect(const CLASS_6& flag)->std::VAR_19<TBase>
{
CLASS_2 VAR_25 = VAR_4 std::VAR_26<VAR_29>::type;
return VAR_6<TBase, VAR_25>::FUNC_9()->CreateSharedObject(flag);
}
//创建实例
VAR_3<VAR_4 TBase, VAR_4 VAR_29>
VAR_24 auto VAR_30(const CLASS_6& flag)->TBase*
{
CLASS_2 VAR_25 = VAR_4 std::VAR_26<VAR_29>::type;
return VAR_6<TBase, VAR_25>::FUNC_9()->FUNC_7(flag);
}
//创建所有已注册为 TBase 与 TFLG 为标识的的实例
VAR_3<VAR_4 TBase, VAR_4 VAR_29>
VAR_24 VAR_31 FUNC_10()->std::VAR_21<std::VAR_19<TBase>>
{
VAR_9 VAR_25 = VAR_4 std::VAR_26<VAR_29>::type;
std::VAR_21<std::VAR_19<TBase>> VAR_20;
VAR_6<TBase, VAR_25>::FUNC_9()->CreateAllSharedObject(VAR_20);
return VAR_20;
}
};
}
| 0.742911 | {'VAR_0': 'shared', 'CLASS_0': 'class', 'VAR_1': 'class', 'VAR_2': 'TemplatedObjectFactoryWrapper', 'VAR_3': 'template', 'VAR_4': 'typename', 'VAR_5': 'TOBJFLG', 'ID_0': 'TOBJFLG', 'CLASS_1': 'TOBJFLG', 'VAR_6': 'TemplatedObjectFactory', 'FUNC_0': 'TemplatedObjectFactory', 'VAR_7': 'nbase', 'VAR_8': 'Singleton', 'VAR_9': 'using', 'CLASS_2': 'using', 'VAR_10': '', 'CLASS_3': '', 'CLASS_4': 'friend', 'VAR_11': 'TClass', 'VAR_12': 'dynamic_cast', 'VAR_13': 'new', 'VAR_14': 'void', 'FUNC_1': 'AddCreateFunction', 'VAR_15': 'AddCreateFunction', 'VAR_16': 'flg', 'CLASS_5': 'it', 'VAR_17': 'it', 'FUNC_2': 'end', 'VAR_18': 'item', 'FUNC_3': 'emplace_back', 'FUNC_4': 'make_pair', 'FUNC_5': 'bind', 'VAR_19': 'shared_ptr', 'FUNC_6': 'second', 'FUNC_7': 'CreateObject', 'VAR_20': 'ret', 'VAR_21': 'list', 'VAR_22': 'objects', 'VAR_23': 'function', 'VAR_24': 'static', 'FUNC_8': 'RegisteredOjbect', 'VAR_25': 'TDecayType', 'VAR_26': 'decay', 'VAR_27': 'is_base_of', 'VAR_28': 'value', 'FUNC_9': 'GetInstance', 'VAR_29': 'TFLG', 'CLASS_6': 'TFLG', 'VAR_30': 'InstantiateRegisteredOjbect', 'VAR_31': 'auto', 'FUNC_10': 'InstantiateAllRegisteredSharedOjbect'} |
/**
* @brief Used to parse advertising data and scan response data
* @param[in] scan_info point to scan information data.
* @retval void
*/
void bt_mesh_scatternet_app_parse_scan_info(T_LE_SCAN_INFO *scan_info)
{
uint8_t buffer[32];
uint8_t pos = 0;
while (pos < scan_info->data_len)
{
uint8_t length = scan_info->data[pos++];
uint8_t type;
if ((length > 0x01) && ((pos + length) <= 31))
{
memcpy(buffer, scan_info->data + pos + 1, length - 1);
type = scan_info->data[pos];
APP_PRINT_TRACE2("ble_scatternet_app_parse_scan_info: AD Structure Info: AD type 0x%x, AD Data Length %d", type,
length - 1);
switch (type)
{
case GAP_ADTYPE_FLAGS:
{
uint8_t flags = scan_info->data[pos + 1];
APP_PRINT_INFO1("GAP_ADTYPE_FLAGS: 0x%x", flags);
BLE_PRINT("GAP_ADTYPE_FLAGS: 0x%x\n\r", flags);
}
break;
case GAP_ADTYPE_16BIT_MORE:
case GAP_ADTYPE_16BIT_COMPLETE:
case GAP_ADTYPE_SERVICES_LIST_16BIT:
{
uint16_t *p_uuid = (uint16_t *)(buffer);
uint8_t i = length - 1;
while (i >= 2)
{
APP_PRINT_INFO1("GAP_ADTYPE_16BIT_XXX: 0x%x", *p_uuid);
BLE_PRINT("GAP_ADTYPE_16BIT_XXX: 0x%x\n\r", *p_uuid);
p_uuid ++;
i -= 2;
}
}
break;
case GAP_ADTYPE_32BIT_MORE:
case GAP_ADTYPE_32BIT_COMPLETE:
{
uint32_t *p_uuid = (uint32_t *)(buffer);
uint8_t i = length - 1;
while (i >= 4)
{
APP_PRINT_INFO1("GAP_ADTYPE_32BIT_XXX: 0x%x", *p_uuid);
BLE_PRINT("GAP_ADTYPE_32BIT_XXX: 0x%x\n\r", (unsigned int)*p_uuid);
p_uuid ++;
i -= 4;
}
}
break;
case GAP_ADTYPE_128BIT_MORE:
case GAP_ADTYPE_128BIT_COMPLETE:
case GAP_ADTYPE_SERVICES_LIST_128BIT:
{
uint32_t *p_uuid = (uint32_t *)(buffer);
APP_PRINT_INFO4("GAP_ADTYPE_128BIT_XXX: 0x%8.8x%8.8x%8.8x%8.8x",
p_uuid[3], p_uuid[2], p_uuid[1], p_uuid[0]);
BLE_PRINT("GAP_ADTYPE_128BIT_XXX: 0x%8.8x%8.8x%8.8x%8.8x\n\r",
(unsigned int)p_uuid[3], (unsigned int)p_uuid[2], (unsigned int)p_uuid[1], (unsigned int)p_uuid[0]);
}
break;
case GAP_ADTYPE_LOCAL_NAME_SHORT:
case GAP_ADTYPE_LOCAL_NAME_COMPLETE:
{
buffer[length - 1] = '\0';
APP_PRINT_INFO1("GAP_ADTYPE_LOCAL_NAME_XXX: %s", TRACE_STRING(buffer));
BLE_PRINT("GAP_ADTYPE_LOCAL_NAME_XXX: %s\n\r", buffer);
}
break;
case GAP_ADTYPE_POWER_LEVEL:
{
APP_PRINT_INFO1("GAP_ADTYPE_POWER_LEVEL: 0x%x", scan_info->data[pos + 1]);
BLE_PRINT("GAP_ADTYPE_POWER_LEVEL: 0x%x\n\r", scan_info->data[pos + 1]);
}
break;
case GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE:
{
uint16_t *p_min = (uint16_t *)(buffer);
uint16_t *p_max = p_min + 1;
APP_PRINT_INFO2("GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE: 0x%x - 0x%x", *p_min,
*p_max);
BLE_PRINT("GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE: 0x%x - 0x%x\n\r", *p_min,
*p_max);
}
break;
case GAP_ADTYPE_SERVICE_DATA:
{
uint16_t *p_uuid = (uint16_t *)(buffer);
uint8_t data_len = length - 3;
APP_PRINT_INFO3("GAP_ADTYPE_SERVICE_DATA: UUID 0x%x, len %d, data %b", *p_uuid,
data_len, TRACE_BINARY(data_len, &buffer[2]));
BLE_PRINT("GAP_ADTYPE_SERVICE_DATA: UUID 0x%x, len %d\n\r", *p_uuid,
data_len);
}
break;
case GAP_ADTYPE_APPEARANCE:
{
uint16_t *p_appearance = (uint16_t *)(buffer);
APP_PRINT_INFO1("GAP_ADTYPE_APPEARANCE: %d", *p_appearance);
BLE_PRINT("GAP_ADTYPE_APPEARANCE: %d\n\r", *p_appearance);
}
break;
case GAP_ADTYPE_MANUFACTURER_SPECIFIC:
{
uint8_t data_len = length - 3;
uint16_t *p_company_id = (uint16_t *)(buffer);
APP_PRINT_INFO3("GAP_ADTYPE_MANUFACTURER_SPECIFIC: company_id 0x%x, len %d, data %b",
*p_company_id, data_len, TRACE_BINARY(data_len, &buffer[2]));
BLE_PRINT("GAP_ADTYPE_MANUFACTURER_SPECIFIC: company_id 0x%x, len %d\n\r",
*p_company_id, data_len);
}
break;
default:
{
uint8_t i = 0;
for (i = 0; i < (length - 1); i++)
{
APP_PRINT_INFO1(" AD Data: Unhandled Data = 0x%x", scan_info->data[pos + i]);
}
}
break;
}
}
pos += length;
}
} | /**
* @brief Used to parse advertising data and scan response data
* @param[in] scan_info point to scan information data.
* @retval void
*/
void FUNC_0(T_LE_SCAN_INFO *VAR_0)
{
uint8_t buffer[32];
uint8_t pos = 0;
while (pos < VAR_0->data_len)
{
uint8_t length = VAR_0->data[pos++];
uint8_t type;
if ((length > 0x01) && ((pos + length) <= 31))
{
FUNC_1(buffer, VAR_0->data + pos + 1, length - 1);
type = VAR_0->data[pos];
FUNC_2("ble_scatternet_app_parse_scan_info: AD Structure Info: AD type 0x%x, AD Data Length %d", type,
length - 1);
switch (type)
{
case VAR_1:
{
uint8_t flags = VAR_0->data[pos + 1];
FUNC_3("GAP_ADTYPE_FLAGS: 0x%x", flags);
BLE_PRINT("GAP_ADTYPE_FLAGS: 0x%x\n\r", flags);
}
break;
case VAR_2:
case GAP_ADTYPE_16BIT_COMPLETE:
case VAR_3:
{
uint16_t *p_uuid = (uint16_t *)(buffer);
uint8_t VAR_4 = length - 1;
while (VAR_4 >= 2)
{
FUNC_3("GAP_ADTYPE_16BIT_XXX: 0x%x", *p_uuid);
BLE_PRINT("GAP_ADTYPE_16BIT_XXX: 0x%x\n\r", *p_uuid);
p_uuid ++;
VAR_4 -= 2;
}
}
break;
case VAR_5:
case VAR_6:
{
uint32_t *p_uuid = (uint32_t *)(buffer);
uint8_t VAR_4 = length - 1;
while (VAR_4 >= 4)
{
FUNC_3("GAP_ADTYPE_32BIT_XXX: 0x%x", *p_uuid);
BLE_PRINT("GAP_ADTYPE_32BIT_XXX: 0x%x\n\r", (unsigned int)*p_uuid);
p_uuid ++;
VAR_4 -= 4;
}
}
break;
case GAP_ADTYPE_128BIT_MORE:
case GAP_ADTYPE_128BIT_COMPLETE:
case GAP_ADTYPE_SERVICES_LIST_128BIT:
{
uint32_t *p_uuid = (uint32_t *)(buffer);
FUNC_4("GAP_ADTYPE_128BIT_XXX: 0x%8.8x%8.8x%8.8x%8.8x",
p_uuid[3], p_uuid[2], p_uuid[1], p_uuid[0]);
BLE_PRINT("GAP_ADTYPE_128BIT_XXX: 0x%8.8x%8.8x%8.8x%8.8x\n\r",
(unsigned int)p_uuid[3], (unsigned int)p_uuid[2], (unsigned int)p_uuid[1], (unsigned int)p_uuid[0]);
}
break;
case GAP_ADTYPE_LOCAL_NAME_SHORT:
case GAP_ADTYPE_LOCAL_NAME_COMPLETE:
{
buffer[length - 1] = '\0';
FUNC_3("GAP_ADTYPE_LOCAL_NAME_XXX: %s", FUNC_5(buffer));
BLE_PRINT("GAP_ADTYPE_LOCAL_NAME_XXX: %s\n\r", buffer);
}
break;
case VAR_7:
{
FUNC_3("GAP_ADTYPE_POWER_LEVEL: 0x%x", VAR_0->data[pos + 1]);
BLE_PRINT("GAP_ADTYPE_POWER_LEVEL: 0x%x\n\r", VAR_0->data[pos + 1]);
}
break;
case VAR_8:
{
uint16_t *p_min = (uint16_t *)(buffer);
uint16_t *VAR_9 = p_min + 1;
FUNC_6("GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE: 0x%x - 0x%x", *p_min,
*VAR_9);
BLE_PRINT("GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE: 0x%x - 0x%x\n\r", *p_min,
*VAR_9);
}
break;
case GAP_ADTYPE_SERVICE_DATA:
{
uint16_t *p_uuid = (uint16_t *)(buffer);
uint8_t data_len = length - 3;
FUNC_7("GAP_ADTYPE_SERVICE_DATA: UUID 0x%x, len %d, data %b", *p_uuid,
data_len, TRACE_BINARY(data_len, &buffer[2]));
BLE_PRINT("GAP_ADTYPE_SERVICE_DATA: UUID 0x%x, len %d\n\r", *p_uuid,
data_len);
}
break;
case VAR_10:
{
uint16_t *VAR_11 = (uint16_t *)(buffer);
FUNC_3("GAP_ADTYPE_APPEARANCE: %d", *VAR_11);
BLE_PRINT("GAP_ADTYPE_APPEARANCE: %d\n\r", *VAR_11);
}
break;
case VAR_12:
{
uint8_t data_len = length - 3;
uint16_t *p_company_id = (uint16_t *)(buffer);
FUNC_7("GAP_ADTYPE_MANUFACTURER_SPECIFIC: company_id 0x%x, len %d, data %b",
*p_company_id, data_len, TRACE_BINARY(data_len, &buffer[2]));
BLE_PRINT("GAP_ADTYPE_MANUFACTURER_SPECIFIC: company_id 0x%x, len %d\n\r",
*p_company_id, data_len);
}
break;
default:
{
uint8_t VAR_4 = 0;
for (VAR_4 = 0; VAR_4 < (length - 1); VAR_4++)
{
FUNC_3(" AD Data: Unhandled Data = 0x%x", VAR_0->data[pos + VAR_4]);
}
}
break;
}
}
pos += length;
}
} | 0.594198 | {'FUNC_0': 'bt_mesh_scatternet_app_parse_scan_info', 'VAR_0': 'scan_info', 'FUNC_1': 'memcpy', 'FUNC_2': 'APP_PRINT_TRACE2', 'VAR_1': 'GAP_ADTYPE_FLAGS', 'FUNC_3': 'APP_PRINT_INFO1', 'VAR_2': 'GAP_ADTYPE_16BIT_MORE', 'VAR_3': 'GAP_ADTYPE_SERVICES_LIST_16BIT', 'VAR_4': 'i', 'VAR_5': 'GAP_ADTYPE_32BIT_MORE', 'VAR_6': 'GAP_ADTYPE_32BIT_COMPLETE', 'FUNC_4': 'APP_PRINT_INFO4', 'FUNC_5': 'TRACE_STRING', 'VAR_7': 'GAP_ADTYPE_POWER_LEVEL', 'VAR_8': 'GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE', 'VAR_9': 'p_max', 'FUNC_6': 'APP_PRINT_INFO2', 'FUNC_7': 'APP_PRINT_INFO3', 'VAR_10': 'GAP_ADTYPE_APPEARANCE', 'VAR_11': 'p_appearance', 'VAR_12': 'GAP_ADTYPE_MANUFACTURER_SPECIFIC'} |
/* simpleide.c: Simple 8-bit IDE interface routines
Copyright (c) 2003-2016 <NAME>, <NAME>, <NAME>
Copyright (c) 2015 <NAME>
Copyright (c) 2016 <NAME>
$Id: simpleide.c 817 2016-07-18 11:56:29Z fredm $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Author contact information:
E-mail: <NAME> <<EMAIL>>
*/
#include "config.h"
#include "libspectrum.h"
#include "ide.h"
#include "startup_manager.h"
#include "module.h"
#include "periph.h"
#include "settings.h"
#include "simpleide.h"
#include "ui.h"
/* Private function prototypes */
static libspectrum_byte simpleide_read( libspectrum_word port, libspectrum_byte *attached );
static void simpleide_write( libspectrum_word port, libspectrum_byte data );
/* Data */
static const periph_port_t simpleide_ports[] = {
{ 0x0010, 0x0000, simpleide_read, simpleide_write },
{ 0, 0, NULL, NULL }
};
static const periph_t simpleide_periph = {
/* .option = */ &settings_current.simpleide_active,
/* .ports = */ simpleide_ports,
/* .hard_reset = */ 1,
/* .activate = */ NULL,
};
static libspectrum_ide_channel *simpleide_idechn;
static void simpleide_snapshot_enabled( libspectrum_snap *snap );
static void simpleide_to_snapshot( libspectrum_snap *snap );
static module_info_t simpleide_module_info = {
/* .reset = */ simpleide_reset,
/* .romcs = */ NULL,
/* .snapshot_enabled = */ simpleide_snapshot_enabled,
/* .snapshot_from = */ NULL,
/* .snapshot_to = */ simpleide_to_snapshot,
};
/* Housekeeping functions */
static int
simpleide_init( void *context )
{
int error;
simpleide_idechn = libspectrum_ide_alloc( LIBSPECTRUM_IDE_DATA8 );
ui_menu_activate( UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_MASTER_EJECT, 0 );
ui_menu_activate( UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_SLAVE_EJECT, 0 );
if( settings_current.simpleide_master_file ) {
error = libspectrum_ide_insert( simpleide_idechn, LIBSPECTRUM_IDE_MASTER,
settings_current.simpleide_master_file );
if( error ) return error;
ui_menu_activate( UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_MASTER_EJECT, 1 );
}
if( settings_current.simpleide_slave_file ) {
error = libspectrum_ide_insert( simpleide_idechn, LIBSPECTRUM_IDE_SLAVE,
settings_current.simpleide_slave_file );
if( error ) return error;
ui_menu_activate( UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_SLAVE_EJECT, 1 );
}
module_register( &simpleide_module_info );
periph_register( PERIPH_TYPE_SIMPLEIDE, &simpleide_periph );
return 0;
}
static void
simpleide_end( void )
{
libspectrum_ide_free( simpleide_idechn );
}
void
simpleide_register_startup( void )
{
startup_manager_module dependencies[] = {
STARTUP_MANAGER_MODULE_DISPLAY,
STARTUP_MANAGER_MODULE_SETUID
};
startup_manager_register( STARTUP_MANAGER_MODULE_SIMPLEIDE, dependencies,
ARRAY_SIZE( dependencies ), simpleide_init, NULL,
simpleide_end );
}
void
simpleide_reset( int hard_reset GCC_UNUSED )
{
libspectrum_ide_reset( simpleide_idechn );
}
int
simpleide_insert( const char *filename, libspectrum_ide_unit unit )
{
char **setting;
ui_menu_item item;
switch( unit ) {
case LIBSPECTRUM_IDE_MASTER:
setting = &settings_current.simpleide_master_file;
item = UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_MASTER_EJECT;
break;
case LIBSPECTRUM_IDE_SLAVE:
setting = &settings_current.simpleide_slave_file;
item = UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_SLAVE_EJECT;
break;
default: return 1;
}
return ide_insert( filename, simpleide_idechn, unit, simpleide_commit,
setting, item );
}
int
simpleide_commit( libspectrum_ide_unit unit )
{
int error;
error = libspectrum_ide_commit( simpleide_idechn, unit );
return error;
}
int
simpleide_eject( libspectrum_ide_unit unit )
{
char **setting;
ui_menu_item item;
switch( unit ) {
case LIBSPECTRUM_IDE_MASTER:
setting = &settings_current.simpleide_master_file;
item = UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_MASTER_EJECT;
break;
case LIBSPECTRUM_IDE_SLAVE:
setting = &settings_current.simpleide_slave_file;
item = UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_SLAVE_EJECT;
break;
default: return 1;
}
return ide_eject( simpleide_idechn, unit, simpleide_commit, setting, item );
}
/* Port read/writes */
static libspectrum_byte
simpleide_read( libspectrum_word port, libspectrum_byte *attached )
{
libspectrum_ide_register idereg;
*attached = 0xff; /* TODO: check this */
idereg = ( ( port >> 8 ) & 0x01 ) | ( ( port >> 11 ) & 0x06 );
return libspectrum_ide_read( simpleide_idechn, idereg );
}
static void
simpleide_write( libspectrum_word port, libspectrum_byte data )
{
libspectrum_ide_register idereg;
idereg = ( ( port >> 8 ) & 0x01 ) | ( ( port >> 11 ) & 0x06 );
libspectrum_ide_write( simpleide_idechn, idereg, data );
}
static void
simpleide_snapshot_enabled( libspectrum_snap *snap )
{
if( libspectrum_snap_simpleide_active( snap ) )
settings_current.simpleide_active = 1;
}
static void
simpleide_to_snapshot( libspectrum_snap *snap )
{
if( !settings_current.simpleide_active ) return;
libspectrum_snap_set_simpleide_active( snap, 1 );
}
| /* simpleide.c: Simple 8-bit IDE interface routines
Copyright (c) 2003-2016 <NAME>, <NAME>, <NAME>
Copyright (c) 2015 <NAME>
Copyright (c) 2016 <NAME>
$Id: simpleide.c 817 2016-07-18 11:56:29Z fredm $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Author contact information:
E-mail: <NAME> <<EMAIL>>
*/
#include "config.h"
#include "libspectrum.h"
#include "ide.h"
#include "startup_manager.h"
#include "module.h"
#include "periph.h"
#include "settings.h"
#include "simpleide.h"
#include "ui.h"
/* Private function prototypes */
static libspectrum_byte simpleide_read( libspectrum_word port, libspectrum_byte *attached );
static void simpleide_write( libspectrum_word port, libspectrum_byte VAR_0 );
/* Data */
static const periph_port_t simpleide_ports[] = {
{ 0x0010, 0x0000, simpleide_read, simpleide_write },
{ 0, 0, NULL, NULL }
};
static const periph_t simpleide_periph = {
/* .option = */ &settings_current.VAR_1,
/* .ports = */ simpleide_ports,
/* .hard_reset = */ 1,
/* .activate = */ NULL,
};
static libspectrum_ide_channel *simpleide_idechn;
static void simpleide_snapshot_enabled( libspectrum_snap *snap );
static void simpleide_to_snapshot( libspectrum_snap *snap );
static module_info_t simpleide_module_info = {
/* .reset = */ simpleide_reset,
/* .romcs = */ NULL,
/* .snapshot_enabled = */ simpleide_snapshot_enabled,
/* .snapshot_from = */ NULL,
/* .snapshot_to = */ simpleide_to_snapshot,
};
/* Housekeeping functions */
static int
simpleide_init( void *context )
{
int error;
simpleide_idechn = libspectrum_ide_alloc( LIBSPECTRUM_IDE_DATA8 );
ui_menu_activate( UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_MASTER_EJECT, 0 );
ui_menu_activate( UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_SLAVE_EJECT, 0 );
if( settings_current.simpleide_master_file ) {
error = libspectrum_ide_insert( simpleide_idechn, LIBSPECTRUM_IDE_MASTER,
settings_current.simpleide_master_file );
if( error ) return error;
ui_menu_activate( UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_MASTER_EJECT, 1 );
}
if( settings_current.simpleide_slave_file ) {
error = libspectrum_ide_insert( simpleide_idechn, LIBSPECTRUM_IDE_SLAVE,
settings_current.simpleide_slave_file );
if( error ) return error;
ui_menu_activate( UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_SLAVE_EJECT, 1 );
}
module_register( &simpleide_module_info );
periph_register( PERIPH_TYPE_SIMPLEIDE, &simpleide_periph );
return 0;
}
static void
simpleide_end( void )
{
libspectrum_ide_free( simpleide_idechn );
}
void
simpleide_register_startup( void )
{
startup_manager_module dependencies[] = {
STARTUP_MANAGER_MODULE_DISPLAY,
STARTUP_MANAGER_MODULE_SETUID
};
startup_manager_register( STARTUP_MANAGER_MODULE_SIMPLEIDE, dependencies,
ARRAY_SIZE( dependencies ), simpleide_init, NULL,
simpleide_end );
}
void
simpleide_reset( int hard_reset GCC_UNUSED )
{
libspectrum_ide_reset( simpleide_idechn );
}
int
simpleide_insert( const char *filename, libspectrum_ide_unit unit )
{
char **setting;
ui_menu_item item;
switch( unit ) {
case LIBSPECTRUM_IDE_MASTER:
setting = &settings_current.simpleide_master_file;
item = UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_MASTER_EJECT;
break;
case LIBSPECTRUM_IDE_SLAVE:
setting = &settings_current.simpleide_slave_file;
item = UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_SLAVE_EJECT;
break;
default: return 1;
}
return ide_insert( filename, simpleide_idechn, unit, simpleide_commit,
setting, item );
}
int
simpleide_commit( libspectrum_ide_unit unit )
{
int error;
error = libspectrum_ide_commit( simpleide_idechn, unit );
return error;
}
int
simpleide_eject( libspectrum_ide_unit unit )
{
char **setting;
ui_menu_item item;
switch( unit ) {
case LIBSPECTRUM_IDE_MASTER:
setting = &settings_current.simpleide_master_file;
item = UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_MASTER_EJECT;
break;
case LIBSPECTRUM_IDE_SLAVE:
setting = &settings_current.simpleide_slave_file;
item = UI_MENU_ITEM_MEDIA_IDE_SIMPLE8BIT_SLAVE_EJECT;
break;
default: return 1;
}
return ide_eject( simpleide_idechn, unit, simpleide_commit, setting, item );
}
/* Port read/writes */
static libspectrum_byte
simpleide_read( libspectrum_word port, libspectrum_byte *attached )
{
libspectrum_ide_register idereg;
*attached = 0xff; /* TODO: check this */
idereg = ( ( port >> 8 ) & 0x01 ) | ( ( port >> 11 ) & 0x06 );
return libspectrum_ide_read( simpleide_idechn, idereg );
}
static void
simpleide_write( libspectrum_word port, libspectrum_byte VAR_0 )
{
libspectrum_ide_register idereg;
idereg = ( ( port >> 8 ) & 0x01 ) | ( ( port >> 11 ) & 0x06 );
libspectrum_ide_write( simpleide_idechn, idereg, VAR_0 );
}
static void
simpleide_snapshot_enabled( libspectrum_snap *snap )
{
if( libspectrum_snap_simpleide_active( snap ) )
settings_current.VAR_1 = 1;
}
static void
simpleide_to_snapshot( libspectrum_snap *snap )
{
if( !settings_current.VAR_1 ) return;
libspectrum_snap_set_simpleide_active( snap, 1 );
}
| 0.10378 | {'VAR_0': 'data', 'VAR_1': 'simpleide_active'} |
//
// RPN_Calc.h
// RPN-Calc
//
// Created by <NAME> on 12/18/19.
// Copyright © 2019 <NAME>. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for RPN_Calc.
FOUNDATION_EXPORT double RPN_CalcVersionNumber;
//! Project version string for RPN_Calc.
FOUNDATION_EXPORT const unsigned char RPN_CalcVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <RPN_Calc/PublicHeader.h>
| //
// RPN_Calc.h
// RPN-Calc
//
// Created by <NAME> on 12/18/19.
// Copyright © 2019 <NAME>. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for RPN_Calc.
CLASS_0 VAR_0 VAR_1;
//! Project version string for RPN_Calc.
CLASS_0 const VAR_2 char RPN_CalcVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <RPN_Calc/PublicHeader.h>
| 0.827824 | {'CLASS_0': 'FOUNDATION_EXPORT', 'VAR_0': 'double', 'VAR_1': 'RPN_CalcVersionNumber', 'VAR_2': 'unsigned'} |
#include<stdio.h>
int main()
{
int a,b,c;
int istriangle=0;
printf("enter 3 integers which are sides of triangle\n");
scanf("%d%d%d",&a,&b,&c);
printf("a=%d\t,b=%d\t,c=%d",a,b,c);
// to check is it a triangle or not
if( a<b+c && b<a+c && c<a+b )
istriangle=1;
else
istriangle =0;
;
if (istriangle==1)
if ((a==b) && (b==c))
printf("equilateral triangle\n");
else if ((a!=b) && (a!=c) && (b!=c))
printf("scalene triangle\n");
else
printf("isosceles triangle\n");
else
printf("Not a triangle\n");
return 0;
}
| #include<stdio.h>
int main()
{
int a,b,c;
int istriangle=0;
printf("enter 3 integers which are sides of triangle\n");
scanf("%d%d%d",&a,&b,&c);
printf("a=%d\t,b=%d\t,c=%d",a,b,c);
// to check is it a triangle or not
if( a<b+c && b<a+c && c<a+b )
istriangle=1;
else
istriangle =0;
;
if (istriangle==1)
if ((a==b) && (b==c))
printf("equilateral triangle\n");
else if ((a!=b) && (a!=c) && (b!=c))
printf("scalene triangle\n");
else
printf("isosceles triangle\n");
else
printf("Not a triangle\n");
return 0;
}
| 0.013408 | {} |
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "btm_snoop.h"
#include <stdio.h>
#include <securec.h>
#include <sys/time.h>
#include "hci/hci.h"
#include "platform/include/allocator.h"
#include "platform/include/bt_endian.h"
#include "platform/include/mutex.h"
#include "platform/include/queue.h"
#include "platform/include/reactor.h"
#include "platform/include/thread.h"
#include "btm.h"
#include "btm/btm_snoop_filter.h"
#define SNOOP_INDENTIFICATION_PATTERN \
{ \
0x62, 0x74, 0x73, 0x6e, 0x6f, 0x6f, 0x70, 0x00 \
}
#define SNOOP_VERSION_NUMBER 1
#define SNOOP_DATALINK_TYPE_H4 1002
#define MICROSECOND_1970BASE 62168256000000000
#define H4_HEADER_CMD 0x01
#define H4_HEADER_ACLDATA 0x02
#define H4_HEADER_EVENT 0x04
#define SNOOP_PACKET_FLAG_SENT 0x00
#define SNOOP_PACKET_FLAG_RECEIVED 0x01
#define SNOOP_PACKET_FLAG_DATA 0x00
#define SNOOP_PACKET_FLAG_CMD_EVENT 0x02
#define SNOOP_LAST_FILE_TAIL ".last"
#define MICROSECOND 1000000
#define SNOOP_BLOCK_IOV_COUNT 3
#define HCI_LOG_PATH "./hci.log"
#define HCI_H4_HEADER_LEN 1
#pragma pack(1)
typedef struct {
uint8_t identificationPattern[8]; // { 0x62, 0x74, 0x73, 0x6e, 0x6f, 0x6f, 0x70, 0x00 }
uint32_t versionNumber; // 1
uint32_t datalinkType; // 1002
} BtmSnoopFileHeader;
typedef struct {
uint32_t originalLength;
uint32_t includedLength;
uint32_t packetFlags;
uint32_t cumulativeDrops;
uint64_t timestamp; // microseconds
} BtmSnoopPacketHeader;
#pragma pack()
static bool g_output = false;
static char *g_outputPath = NULL;
static FILE *g_outputFile = NULL;
static bool g_hciLogOuput = false;
static Mutex *g_outputMutex = NULL;
static void GetH4HeaderAndPacketFlags(uint8_t type, uint8_t *h4Header, uint32_t *packetFlags)
{
switch (type) {
case TRANSMISSON_TYPE_H2C_CMD:
*h4Header = H4_HEADER_CMD;
*packetFlags = SNOOP_PACKET_FLAG_SENT | SNOOP_PACKET_FLAG_CMD_EVENT;
break;
case TRANSMISSON_TYPE_C2H_EVENT:
*h4Header = H4_HEADER_EVENT;
*packetFlags = SNOOP_PACKET_FLAG_RECEIVED | SNOOP_PACKET_FLAG_CMD_EVENT;
break;
case TRANSMISSON_TYPE_H2C_DATA:
*h4Header = H4_HEADER_ACLDATA;
*packetFlags = SNOOP_PACKET_FLAG_SENT | SNOOP_PACKET_FLAG_DATA;
break;
case TRANSMISSON_TYPE_C2H_DATA:
*h4Header = H4_HEADER_ACLDATA;
*packetFlags = SNOOP_PACKET_FLAG_RECEIVED | SNOOP_PACKET_FLAG_DATA;
break;
default:
break;
}
}
static void BtmSnoopOutput(uint8_t type, const uint8_t *data, uint16_t length)
{
struct timeval tv;
gettimeofday(&tv, NULL);
const uint64_t timestamp = MICROSECOND_1970BASE + tv.tv_sec * MICROSECOND + tv.tv_usec;
uint8_t h4Header = 0;
uint32_t packetFlags = 0;
GetH4HeaderAndPacketFlags(type, &h4Header, &packetFlags);
uint16_t originalLength = length + 1;
uint16_t includedLength = length + 1;
const uint8_t *outputData = data;
BtmHciFilter(type, &outputData, originalLength, &includedLength);
BtmSnoopPacketHeader header = {
.originalLength = H2BE_32(originalLength),
.includedLength = H2BE_32(includedLength),
.cumulativeDrops = H2BE_32(0),
.packetFlags = H2BE_32(packetFlags),
.timestamp = H2BE_64(timestamp),
};
MutexLock(g_outputMutex);
(void)fwrite(&header, 1, sizeof(BtmSnoopPacketHeader), g_outputFile);
(void)fwrite(&h4Header, 1, HCI_H4_HEADER_LEN, g_outputFile);
(void)fwrite(outputData, 1, includedLength - HCI_H4_HEADER_LEN, g_outputFile);
fflush(g_outputFile);
if (outputData != data) {
MEM_MALLOC.free((void *)outputData);
}
MutexUnlock(g_outputMutex);
}
static void BtmOnHciTransmission(uint8_t type, const uint8_t *data, uint16_t length)
{
BtmSnoopOutput(type, data, length);
}
static void BtmWriteSnoopFileHeader()
{
BtmSnoopFileHeader header = {
.identificationPattern = SNOOP_INDENTIFICATION_PATTERN,
.versionNumber = H2BE_32(SNOOP_VERSION_NUMBER),
.datalinkType = H2BE_32(SNOOP_DATALINK_TYPE_H4),
};
MutexLock(g_outputMutex);
(void)fwrite(&header, 1, sizeof(BtmSnoopFileHeader), g_outputFile);
fflush(g_outputFile);
MutexUnlock(g_outputMutex);
}
static bool BtmIsFileExists(const char *path)
{
bool exists = false;
FILE *file = fopen(path, "r");
if (file != NULL) {
exists = true;
fclose(file);
}
return exists;
}
static void BtmPrepareSnoopFile()
{
if (g_hciLogOuput) {
bool exists = BtmIsFileExists(HCI_LOG_PATH);
if (exists) {
g_outputFile = fopen(HCI_LOG_PATH, "a");
if (g_outputFile == NULL) {
return;
}
} else {
g_outputFile = fopen(HCI_LOG_PATH, "w");
if (g_outputFile == NULL) {
return;
}
BtmWriteSnoopFileHeader();
}
} else {
bool exists = BtmIsFileExists(g_outputPath);
if (exists) {
const int length = strlen(g_outputPath) + strlen(SNOOP_LAST_FILE_TAIL) + 1;
char *bakPath = MEM_CALLOC.alloc(length);
if (bakPath != NULL) {
(void)strcpy_s(bakPath, length, g_outputPath);
(void)strcat_s(bakPath, length, SNOOP_LAST_FILE_TAIL);
rename(g_outputPath, bakPath);
MEM_CALLOC.free(bakPath);
}
}
g_outputFile = fopen(g_outputPath, "w");
if (g_outputFile == NULL) {
return;
}
BtmWriteSnoopFileHeader();
}
}
static void BtmCloseSnoopFile()
{
if (g_outputFile != NULL) {
fclose(g_outputFile);
g_outputFile = NULL;
}
}
int BTM_SetSnoopFilePath(const char *path, uint16_t length)
{
g_outputPath = (char *)MEM_MALLOC.alloc(length + 1);
if (g_outputPath == NULL) {
return BT_NO_MEMORY;
}
(void)memcpy_s(g_outputPath, length + 1, path, length);
g_outputPath[length] = '\0';
return BT_NO_ERROR;
}
int BTM_EnableSnoopFileOutput(bool filter)
{
g_output = true;
if (filter) {
BtmEnableSnoopFilter();
} else {
BtmDisableSnoopFilter();
}
return BT_NO_ERROR;
}
int BTM_DisableSnoopFileOutput()
{
if (g_output) {
BtmDisableSnoopFilter();
}
g_output = false;
return BT_NO_ERROR;
}
void BtmStartSnoopOutput()
{
if (g_hciLogOuput || (g_output && g_outputPath != NULL)) {
BtmPrepareSnoopFile();
HCI_SetTransmissionCaptureCallback(BtmOnHciTransmission);
HCI_EnableTransmissionCapture();
}
}
void BtmStopSnoopOutput()
{
HCI_DisableTransmissionCapture();
BtmCloseSnoopFile();
}
void BtmInitSnoop()
{
g_outputMutex = MutexCreate();
BtmInitSnoopFilter();
}
void BtmCloseSnoop()
{
g_output = false;
g_hciLogOuput = false;
BtmCloseSnoopFilter();
if (g_outputMutex != NULL) {
MutexDelete(g_outputMutex);
g_outputMutex = NULL;
}
if (g_outputPath != NULL) {
MEM_MALLOC.free(g_outputPath);
g_outputPath = NULL;
}
}
int BTM_EnableHciLogOutput(bool filter)
{
g_hciLogOuput = true;
if (filter) {
BtmEnableSnoopFilter();
} else {
BtmDisableSnoopFilter();
}
return BT_NO_ERROR;
}
int BTM_DisableHciLogOutput()
{
if (g_hciLogOuput) {
BtmDisableSnoopFilter();
}
g_hciLogOuput = false;
return BT_NO_ERROR;
} | /*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "btm_snoop.h"
#include <IMPORT_0>
#include <securec.h>
#include <sys/time.h>
#include "hci/hci.h"
#include "platform/include/allocator.h"
#include "IMPORT_1"
#include "platform/include/mutex.h"
#include "IMPORT_2"
#include "platform/include/reactor.h"
#include "platform/include/thread.h"
#include "btm.h"
#include "btm/btm_snoop_filter.h"
#define SNOOP_INDENTIFICATION_PATTERN \
{ \
0x62, 0x74, 0x73, 0x6e, 0x6f, 0x6f, 0x70, 0x00 \
}
#define SNOOP_VERSION_NUMBER 1
#define SNOOP_DATALINK_TYPE_H4 1002
#define MICROSECOND_1970BASE 62168256000000000
#define H4_HEADER_CMD 0x01
#define H4_HEADER_ACLDATA 0x02
#define VAR_0 0x04
#define SNOOP_PACKET_FLAG_SENT 0x00
#define VAR_1 0x01
#define VAR_2 0x00
#define VAR_3 0x02
#define SNOOP_LAST_FILE_TAIL ".last"
#define VAR_4 1000000
#define SNOOP_BLOCK_IOV_COUNT 3
#define HCI_LOG_PATH "./hci.log"
#define VAR_5 1
#pragma pack(1)
typedef struct {
uint8_t identificationPattern[8]; // { 0x62, 0x74, 0x73, 0x6e, 0x6f, 0x6f, 0x70, 0x00 }
uint32_t VAR_6; // 1
uint32_t datalinkType; // 1002
} BtmSnoopFileHeader;
typedef struct {
uint32_t originalLength;
uint32_t includedLength;
uint32_t packetFlags;
uint32_t cumulativeDrops;
uint64_t timestamp; // microseconds
} BtmSnoopPacketHeader;
#pragma pack()
static bool g_output = false;
static char *g_outputPath = NULL;
static CLASS_0 *g_outputFile = NULL;
static bool g_hciLogOuput = false;
static Mutex *g_outputMutex = NULL;
static void FUNC_0(uint8_t type, uint8_t *h4Header, uint32_t *packetFlags)
{
switch (type) {
case TRANSMISSON_TYPE_H2C_CMD:
*h4Header = H4_HEADER_CMD;
*packetFlags = SNOOP_PACKET_FLAG_SENT | VAR_3;
break;
case TRANSMISSON_TYPE_C2H_EVENT:
*h4Header = VAR_0;
*packetFlags = VAR_1 | VAR_3;
break;
case TRANSMISSON_TYPE_H2C_DATA:
*h4Header = H4_HEADER_ACLDATA;
*packetFlags = SNOOP_PACKET_FLAG_SENT | VAR_2;
break;
case VAR_7:
*h4Header = H4_HEADER_ACLDATA;
*packetFlags = VAR_1 | VAR_2;
break;
default:
break;
}
}
static void FUNC_1(uint8_t type, const uint8_t *data, uint16_t length)
{
struct timeval tv;
gettimeofday(&tv, NULL);
const uint64_t timestamp = MICROSECOND_1970BASE + tv.tv_sec * VAR_4 + tv.VAR_8;
uint8_t h4Header = 0;
uint32_t packetFlags = 0;
FUNC_0(type, &h4Header, &packetFlags);
uint16_t originalLength = length + 1;
uint16_t includedLength = length + 1;
const uint8_t *outputData = data;
BtmHciFilter(type, &outputData, originalLength, &includedLength);
BtmSnoopPacketHeader VAR_9 = {
.originalLength = FUNC_2(originalLength),
.includedLength = FUNC_2(includedLength),
.cumulativeDrops = FUNC_2(0),
.packetFlags = FUNC_2(packetFlags),
.timestamp = H2BE_64(timestamp),
};
MutexLock(g_outputMutex);
(void)fwrite(&VAR_9, 1, sizeof(BtmSnoopPacketHeader), g_outputFile);
(void)fwrite(&h4Header, 1, VAR_5, g_outputFile);
(void)fwrite(outputData, 1, includedLength - VAR_5, g_outputFile);
FUNC_3(g_outputFile);
if (outputData != data) {
MEM_MALLOC.free((void *)outputData);
}
MutexUnlock(g_outputMutex);
}
static void BtmOnHciTransmission(uint8_t type, const uint8_t *data, uint16_t length)
{
FUNC_1(type, data, length);
}
static void BtmWriteSnoopFileHeader()
{
BtmSnoopFileHeader VAR_9 = {
.identificationPattern = SNOOP_INDENTIFICATION_PATTERN,
.VAR_6 = FUNC_2(SNOOP_VERSION_NUMBER),
.datalinkType = FUNC_2(SNOOP_DATALINK_TYPE_H4),
};
MutexLock(g_outputMutex);
(void)fwrite(&VAR_9, 1, sizeof(BtmSnoopFileHeader), g_outputFile);
FUNC_3(g_outputFile);
MutexUnlock(g_outputMutex);
}
static bool FUNC_4(const char *VAR_10)
{
bool exists = false;
CLASS_0 *file = fopen(VAR_10, "r");
if (file != NULL) {
exists = true;
fclose(file);
}
return exists;
}
static void BtmPrepareSnoopFile()
{
if (g_hciLogOuput) {
bool exists = FUNC_4(HCI_LOG_PATH);
if (exists) {
g_outputFile = fopen(HCI_LOG_PATH, "a");
if (g_outputFile == NULL) {
return;
}
} else {
g_outputFile = fopen(HCI_LOG_PATH, "w");
if (g_outputFile == NULL) {
return;
}
BtmWriteSnoopFileHeader();
}
} else {
bool exists = FUNC_4(g_outputPath);
if (exists) {
const int length = strlen(g_outputPath) + strlen(SNOOP_LAST_FILE_TAIL) + 1;
char *bakPath = MEM_CALLOC.alloc(length);
if (bakPath != NULL) {
(void)FUNC_5(bakPath, length, g_outputPath);
(void)strcat_s(bakPath, length, SNOOP_LAST_FILE_TAIL);
rename(g_outputPath, bakPath);
MEM_CALLOC.free(bakPath);
}
}
g_outputFile = fopen(g_outputPath, "w");
if (g_outputFile == NULL) {
return;
}
BtmWriteSnoopFileHeader();
}
}
static void BtmCloseSnoopFile()
{
if (g_outputFile != NULL) {
fclose(g_outputFile);
g_outputFile = NULL;
}
}
int BTM_SetSnoopFilePath(const char *VAR_10, uint16_t length)
{
g_outputPath = (char *)MEM_MALLOC.alloc(length + 1);
if (g_outputPath == NULL) {
return VAR_11;
}
(void)memcpy_s(g_outputPath, length + 1, VAR_10, length);
g_outputPath[length] = '\0';
return VAR_12;
}
int BTM_EnableSnoopFileOutput(bool VAR_13)
{
g_output = true;
if (VAR_13) {
FUNC_6();
} else {
BtmDisableSnoopFilter();
}
return VAR_12;
}
int FUNC_7()
{
if (g_output) {
BtmDisableSnoopFilter();
}
g_output = false;
return VAR_12;
}
void BtmStartSnoopOutput()
{
if (g_hciLogOuput || (g_output && g_outputPath != NULL)) {
BtmPrepareSnoopFile();
HCI_SetTransmissionCaptureCallback(BtmOnHciTransmission);
HCI_EnableTransmissionCapture();
}
}
void BtmStopSnoopOutput()
{
HCI_DisableTransmissionCapture();
BtmCloseSnoopFile();
}
void BtmInitSnoop()
{
g_outputMutex = MutexCreate();
BtmInitSnoopFilter();
}
void FUNC_8()
{
g_output = false;
g_hciLogOuput = false;
FUNC_9();
if (g_outputMutex != NULL) {
FUNC_10(g_outputMutex);
g_outputMutex = NULL;
}
if (g_outputPath != NULL) {
MEM_MALLOC.free(g_outputPath);
g_outputPath = NULL;
}
}
int FUNC_11(bool VAR_13)
{
g_hciLogOuput = true;
if (VAR_13) {
FUNC_6();
} else {
BtmDisableSnoopFilter();
}
return VAR_12;
}
int BTM_DisableHciLogOutput()
{
if (g_hciLogOuput) {
BtmDisableSnoopFilter();
}
g_hciLogOuput = false;
return VAR_12;
} | 0.301699 | {'IMPORT_0': 'stdio.h', 'IMPORT_1': 'platform/include/bt_endian.h', 'IMPORT_2': 'platform/include/queue.h', 'VAR_0': 'H4_HEADER_EVENT', 'VAR_1': 'SNOOP_PACKET_FLAG_RECEIVED', 'VAR_2': 'SNOOP_PACKET_FLAG_DATA', 'VAR_3': 'SNOOP_PACKET_FLAG_CMD_EVENT', 'VAR_4': 'MICROSECOND', 'VAR_5': 'HCI_H4_HEADER_LEN', 'VAR_6': 'versionNumber', 'CLASS_0': 'FILE', 'FUNC_0': 'GetH4HeaderAndPacketFlags', 'VAR_7': 'TRANSMISSON_TYPE_C2H_DATA', 'FUNC_1': 'BtmSnoopOutput', 'VAR_8': 'tv_usec', 'VAR_9': 'header', 'FUNC_2': 'H2BE_32', 'FUNC_3': 'fflush', 'FUNC_4': 'BtmIsFileExists', 'VAR_10': 'path', 'FUNC_5': 'strcpy_s', 'VAR_11': 'BT_NO_MEMORY', 'VAR_12': 'BT_NO_ERROR', 'VAR_13': 'filter', 'FUNC_6': 'BtmEnableSnoopFilter', 'FUNC_7': 'BTM_DisableSnoopFileOutput', 'FUNC_8': 'BtmCloseSnoop', 'FUNC_9': 'BtmCloseSnoopFilter', 'FUNC_10': 'MutexDelete', 'FUNC_11': 'BTM_EnableHciLogOutput'} |
//
// ICCalculateDeputyWealth.h
// task28
//
// Created by <NAME>. on 12.04.17.
// Copyright © 2017 <NAME>. All rights reserved.
//
#ifndef ICCalculateDeputyWealth_h
#define ICCalculateDeputyWealth_h
#include <stdio.h>
void ICCalculateDeputyWealth (int,int);;
#endif /* ICCalculateDeputyWealth_h */
| //
// ICCalculateDeputyWealth.h
// task28
//
// Created by <NAME>. on 12.04.17.
// Copyright © 2017 <NAME>. All rights reserved.
//
#ifndef VAR_0
#define VAR_0
#include <stdio.h>
void FUNC_0 (int,int);;
#endif /* ICCalculateDeputyWealth_h */
| 0.763058 | {'VAR_0': 'ICCalculateDeputyWealth_h', 'FUNC_0': 'ICCalculateDeputyWealth'} |
/* add a new type decl to this kludge
* this will insert into tdecls and dict_tname
*
* returns 1 on success
* returns 0 on failure
*/
unsigned int ic_kludge_add_tdecl(struct ic_kludge *kludge, struct ic_decl_type *tdecl) {
struct ic_symbol *sym = 0;
char *str = 0;
if (!kludge) {
puts("ic_kludge_add_tdecl: kludge was null");
return 0;
}
if (!tdecl) {
puts("ic_kludge_add_tdecl: tdecl was null");
return 0;
}
if (ic_decl_type_type_params_length(tdecl) > 0) {
if (ic_decl_type_is_instantiated(tdecl)) {
sym = ic_decl_type_full_name(tdecl);
if (!sym) {
puts("ic_kludge_add_tdecl: call to ic_decl_type_full_name failed");
return 0;
}
} else {
sym = ic_decl_type_generic_name(tdecl);
if (!sym) {
puts("ic_kludge_add_tdecl: call to ic_decl_type_generic_name failed");
return 0;
}
}
str = ic_symbol_contents(sym);
if (!str) {
puts("ic_kludge_add_tdecl: call to ic_symbol_contents failed");
return 0;
}
if (ic_dict_exists(&(kludge->dict_tname), str)) {
printf("ic_kludge_add_tdecl: type '%s' already exists on this kludge\n", str);
return 0;
}
if (!ic_dict_insert(&(kludge->dict_tname), str, tdecl)) {
puts("ic_kludge_add_tdecl: call to ic_dict_insert failed");
return 0;
}
} else {
sym = ic_decl_type_full_name(tdecl);
if (!sym) {
puts("ic_kludge_add_tdecl: call to ic_decl_type_full_name failed");
return 0;
}
str = ic_symbol_contents(sym);
if (!str) {
puts("ic_kludge_add_tdecl: call to ic_symbol_contents failed");
return 0;
}
if (ic_dict_exists(&(kludge->dict_tname), str)) {
printf("ic_kludge_add_tdecl: type '%s' already exists on this kludge\n", str);
return 0;
}
if (!ic_dict_insert(&(kludge->dict_tname), str, tdecl)) {
puts("ic_kludge_add_tdecl: call to ic_dict_insert failed");
return 0;
}
}
if (-1 == ic_pvector_append(&(kludge->tdecls), tdecl)) {
return 0;
}
return 1;
} | /* add a new type decl to this kludge
* this will insert into tdecls and dict_tname
*
* returns 1 on success
* returns 0 on failure
*/
unsigned int FUNC_0(struct CLASS_0 *VAR_0, struct CLASS_1 *VAR_1) {
struct CLASS_2 *VAR_2 = 0;
char *VAR_3 = 0;
if (!VAR_0) {
FUNC_1("ic_kludge_add_tdecl: kludge was null");
return 0;
}
if (!VAR_1) {
FUNC_1("ic_kludge_add_tdecl: tdecl was null");
return 0;
}
if (FUNC_2(VAR_1) > 0) {
if (FUNC_3(VAR_1)) {
VAR_2 = FUNC_4(VAR_1);
if (!VAR_2) {
FUNC_1("ic_kludge_add_tdecl: call to ic_decl_type_full_name failed");
return 0;
}
} else {
VAR_2 = FUNC_5(VAR_1);
if (!VAR_2) {
FUNC_1("ic_kludge_add_tdecl: call to ic_decl_type_generic_name failed");
return 0;
}
}
VAR_3 = FUNC_6(VAR_2);
if (!VAR_3) {
FUNC_1("ic_kludge_add_tdecl: call to ic_symbol_contents failed");
return 0;
}
if (FUNC_7(&(VAR_0->VAR_4), VAR_3)) {
FUNC_8("ic_kludge_add_tdecl: type '%s' already exists on this kludge\n", VAR_3);
return 0;
}
if (!FUNC_9(&(VAR_0->VAR_4), VAR_3, VAR_1)) {
FUNC_1("ic_kludge_add_tdecl: call to ic_dict_insert failed");
return 0;
}
} else {
VAR_2 = FUNC_4(VAR_1);
if (!VAR_2) {
FUNC_1("ic_kludge_add_tdecl: call to ic_decl_type_full_name failed");
return 0;
}
VAR_3 = FUNC_6(VAR_2);
if (!VAR_3) {
FUNC_1("ic_kludge_add_tdecl: call to ic_symbol_contents failed");
return 0;
}
if (FUNC_7(&(VAR_0->VAR_4), VAR_3)) {
FUNC_8("ic_kludge_add_tdecl: type '%s' already exists on this kludge\n", VAR_3);
return 0;
}
if (!FUNC_9(&(VAR_0->VAR_4), VAR_3, VAR_1)) {
FUNC_1("ic_kludge_add_tdecl: call to ic_dict_insert failed");
return 0;
}
}
if (-1 == FUNC_10(&(VAR_0->VAR_5), VAR_1)) {
return 0;
}
return 1;
} | 0.999606 | {'FUNC_0': 'ic_kludge_add_tdecl', 'CLASS_0': 'ic_kludge', 'VAR_0': 'kludge', 'CLASS_1': 'ic_decl_type', 'VAR_1': 'tdecl', 'CLASS_2': 'ic_symbol', 'VAR_2': 'sym', 'VAR_3': 'str', 'FUNC_1': 'puts', 'FUNC_2': 'ic_decl_type_type_params_length', 'FUNC_3': 'ic_decl_type_is_instantiated', 'FUNC_4': 'ic_decl_type_full_name', 'FUNC_5': 'ic_decl_type_generic_name', 'FUNC_6': 'ic_symbol_contents', 'FUNC_7': 'ic_dict_exists', 'VAR_4': 'dict_tname', 'FUNC_8': 'printf', 'FUNC_9': 'ic_dict_insert', 'FUNC_10': 'ic_pvector_append', 'VAR_5': 'tdecls'} |
#ifndef _ml_func_
#define _ml_func_
namespace ml {
double DiffPosture(const ml::Posture& p1, const ml::Posture& p2);
Motion& stitch(Motion m1, Motion m2, int warp_width = 20);
std::pair<cml::vector3d, std::vector<cml::vector3d>> difference(const Posture &p2, const Posture &p1);
void add_difference(Posture &p, std::pair<cml::vector3d, std::vector<cml::vector3d>> &diff, double ratio);
std::pair<cml::vector3d, cml::vector3d> difference_root(const Posture &p2, const Posture &p1);
void add_difference_root_direction_height(Posture &p, std::pair<cml::vector3d, cml::vector3d> &diff, double ratio);
double scalarTransitionFunc(const double t, const double range);
std::string write_motions( const std::vector<ml::Motion> &motions, const string &name );
void read_motions( std::vector<ml::Motion> &motions, const string &name );
void warp( ml::Motion * before_m, ml::Motion * after_m );
void warp_root_direction_height( ml::Motion * before_m, ml::Motion * after_m, int before_warp_width, int after_warp_width );
};
#endif | #ifndef VAR_0
#define VAR_0
CLASS_0 VAR_1 {
double FUNC_0(const CLASS_1::VAR_2& VAR_3, const CLASS_1::VAR_2& VAR_4);
Motion& FUNC_1(Motion m1, Motion VAR_5, VAR_6 VAR_7 = 20);
std::VAR_9<VAR_10::VAR_11, VAR_8::VAR_12<VAR_10::VAR_11>> difference(VAR_13 VAR_2 &VAR_4, VAR_13 VAR_2 &VAR_3);
void FUNC_2(CLASS_2 &VAR_14, CLASS_3::VAR_9<VAR_10::VAR_11, CLASS_3::VAR_12<VAR_10::VAR_11>> &diff, double VAR_15);
std::VAR_9<VAR_10::VAR_11, VAR_10::VAR_11> FUNC_3(VAR_13 VAR_2 &VAR_4, VAR_13 VAR_2 &VAR_3);
void add_difference_root_direction_height(CLASS_2 &VAR_14, CLASS_3::VAR_9<VAR_10::VAR_11, CLASS_4::VAR_11> &diff, double VAR_15);
double FUNC_4(const double VAR_16, const double VAR_17);
std::VAR_18 FUNC_5( VAR_13 VAR_8::VAR_12<VAR_1::Motion> &VAR_19, VAR_13 VAR_18 &name );
void FUNC_6( CLASS_3::VAR_12<VAR_1::Motion> &VAR_19, const CLASS_5 &name );
void FUNC_7( CLASS_1::Motion * VAR_20, CLASS_1::Motion * after_m );
void FUNC_8( CLASS_1::Motion * VAR_20, CLASS_1::Motion * after_m, int VAR_21, int VAR_22 );
};
#endif | 0.718084 | {'VAR_0': '_ml_func_', 'CLASS_0': 'namespace', 'VAR_1': 'ml', 'CLASS_1': 'ml', 'FUNC_0': 'DiffPosture', 'VAR_2': 'Posture', 'CLASS_2': 'Posture', 'VAR_3': 'p1', 'VAR_4': 'p2', 'FUNC_1': 'stitch', 'VAR_5': 'm2', 'VAR_6': 'int', 'VAR_7': 'warp_width', 'VAR_8': 'std', 'CLASS_3': 'std', 'VAR_9': 'pair', 'VAR_10': 'cml', 'CLASS_4': 'cml', 'VAR_11': 'vector3d', 'VAR_12': 'vector', 'VAR_13': 'const', 'FUNC_2': 'add_difference', 'VAR_14': 'p', 'VAR_15': 'ratio', 'FUNC_3': 'difference_root', 'FUNC_4': 'scalarTransitionFunc', 'VAR_16': 't', 'VAR_17': 'range', 'VAR_18': 'string', 'CLASS_5': 'string', 'FUNC_5': 'write_motions', 'VAR_19': 'motions', 'FUNC_6': 'read_motions', 'FUNC_7': 'warp', 'VAR_20': 'before_m', 'FUNC_8': 'warp_root_direction_height', 'VAR_21': 'before_warp_width', 'VAR_22': 'after_warp_width'} |
//
// NCBFirstPerihperalManager.h
// NanochapSDK
//
// Created by 刘帅 on 2018/12/12.
// Copyright © 2018年 刘帅. All rights reserved.
//
#import "NCBPeripheralManager.h"
#import "NCBCommonConst.h"
@class NCBFirstPerihperalManager;
@protocol NCBFirstPerihperalManagerDataDelegate <NCBPeripheralManagerDataDelegate>
@optional
/**
时间设置成功回调
@param firstPeripheralManager 外设管理对像
*/
- (void)firstPeripheralManager:(NCBFirstPerihperalManager *_Nonnull)firstPeripheralManager didSetTimeSucceed:(BOOL)succeed;
/**
测试led是否正常回调,需要人工判断
@param firstPeripheralManager 外设管理对像
@param result 测试结果
@param errorCode 测试失败错误码
*/
- (void)firstPeripheralManager:(NCBFirstPerihperalManager *)firstPeripheralManager ledTest:(NCBFactoryTestResult)result errorCode:(NCBFactoryTestErrorCode)errorCode;
/**
测试电池电压是否正常回调
@param firstPeripheralManager 外设管理对像
@param result 测试结果
@param errorCode 测试失败错误码
*/
- (void)firstPeripheralManager:(NCBFirstPerihperalManager *)firstPeripheralManager batteryTest:(NCBFactoryTestResult)result errorCode:(NCBFactoryTestErrorCode)errorCode;
/**
测试充电电路是否正常回调,需要等待插入电源
@param firstPeripheralManager 外设管理对像
@param result 测试结果
@param errorCode 测试失败错误码
*/
- (void)firstPeripheralManager:(NCBFirstPerihperalManager *)firstPeripheralManager chargeTest:(NCBFactoryTestResult)result errorCode:(NCBFactoryTestErrorCode)errorCode;
/**
测试触摸按钮是否正常回调,需要等待
@param firstPeripheralManager 外设管理对像
@param result 测试结果
@param errorCode 测试失败错误码
*/
- (void)firstPeripheralManager:(NCBFirstPerihperalManager *)firstPeripheralManager touchButtonTest:(NCBFactoryTestResult)result errorCode:(NCBFactoryTestErrorCode)errorCode;
/**
测试oled是否正常回调,需要人工判断
@param firstPeripheralManager 外设管理对像
@param result 测试结果
@param errorCode 测试失败错误码
*/
- (void)firstPeripheralManager:(NCBFirstPerihperalManager *)firstPeripheralManager oledTest:(NCBFactoryTestResult)result errorCode:(NCBFactoryTestErrorCode)errorCode;
/**
恢复出厂设置回调
@param firstPeripheralManager 外设管理对像
@param result 恢复出厂设置结果
*/
- (void)firstPeripheralManager:(NCBFirstPerihperalManager *)firstPeripheralManager didRestoreFactorySettingsResult:(NCBRestoreFactorySettingsResult)result;
/**
打印设备当前时间
@param firstPeripheralManager 外设管理对像
@param time 时间信息
*/
- (void)firstPeripheralManager:(NCBFirstPerihperalManager *)firstPeripheralManager deviceTime:(NCBDate)time;
/**
打印设备绑定的用户Id
@param firstPeripheralManager 外设管理对像
@param userId 用户id
*/
- (void)firstPeripheralManager:(NCBFirstPerihperalManager *)firstPeripheralManager bindUserId:(uint64_t)userId;
/**
打印固件版本号
@param firstPeripheralManager 外设管理对像
@param firmwareVersion 固件版本
*/
- (void)firstPeripheralManager:(NCBFirstPerihperalManager *)firstPeripheralManager firmwareVersion:(NSString *)firmwareVersion;
@end
NS_ASSUME_NONNULL_BEGIN
@interface NCBFirstPerihperalManager : NCBPeripheralManager
/// 数据回调
@property (nonatomic, weak, nullable) id<NCBFirstPerihperalManagerDataDelegate> dataDelegate;
/**
设置时间,绑定登录会自动调用,单纯连接需要手动调用
*/
- (void)setTime;
/**
获取历史测量数据
*/
- (void)readHistoryMeasureData;
/**
测试LED是否正常,需要人工选择
*/
- (void)testLedIsNormal;
/**
测试电池电压是否正常
*/
- (void)testBatteryVoltageIsNormal;
/**
测试充电是否正常
*/
- (void)testChargeIsNormal;
/**
测试触摸按键是否正常
*/
- (void)testTouchButtonIsNormal;
/**
测试OLED是否正常,需要人工选择
*/
- (void)testOLEDIsNormal;
/**
进入休眠模式
*/
- (void)testEnterDormancyModel;
/**
恢复出厂设置
*/
- (void)restoreFactorySettings;
/**
打印设备当前时间
*/
- (void)printDeviceCurrentTime;
/**
打印设备绑定id
*/
- (void)printDevieBindId;
/**
打印固件版本
*/
- (void)printDeviceFirmwareVerson;
/**
打印FPGA测量数据
*/
- (void)printFPGAMeasureData;
@end
NS_ASSUME_NONNULL_END
| //
// NCBFirstPerihperalManager.h
// NanochapSDK
//
// Created by 刘帅 on 2018/12/12.
// Copyright © 2018年 刘帅. All rights reserved.
//
#import "NCBPeripheralManager.h"
#import "NCBCommonConst.h"
@CLASS_0 VAR_0;
@protocol VAR_1 <VAR_2>
@VAR_3
/**
时间设置成功回调
@param firstPeripheralManager 外设管理对像
*/
- (void)firstPeripheralManager:(VAR_0 *VAR_4)firstPeripheralManager didSetTimeSucceed:(ID_0)VAR_5;
/**
测试led是否正常回调,需要人工判断
@param firstPeripheralManager 外设管理对像
@param result 测试结果
@param errorCode 测试失败错误码
*/
- (void)firstPeripheralManager:(VAR_0 *)firstPeripheralManager VAR_6:(VAR_7)VAR_8 VAR_9:(VAR_10)VAR_9;
/**
测试电池电压是否正常回调
@param firstPeripheralManager 外设管理对像
@param result 测试结果
@param errorCode 测试失败错误码
*/
- (void)firstPeripheralManager:(VAR_0 *)firstPeripheralManager batteryTest:(VAR_7)VAR_8 VAR_9:(VAR_10)VAR_9;
/**
测试充电电路是否正常回调,需要等待插入电源
@param firstPeripheralManager 外设管理对像
@param result 测试结果
@param errorCode 测试失败错误码
*/
- (void)firstPeripheralManager:(VAR_0 *)firstPeripheralManager chargeTest:(VAR_7)VAR_8 VAR_9:(VAR_10)VAR_9;
/**
测试触摸按钮是否正常回调,需要等待
@param firstPeripheralManager 外设管理对像
@param result 测试结果
@param errorCode 测试失败错误码
*/
- (void)firstPeripheralManager:(VAR_0 *)firstPeripheralManager VAR_11:(VAR_7)VAR_8 VAR_9:(VAR_10)VAR_9;
/**
测试oled是否正常回调,需要人工判断
@param firstPeripheralManager 外设管理对像
@param result 测试结果
@param errorCode 测试失败错误码
*/
- (void)firstPeripheralManager:(VAR_0 *)firstPeripheralManager oledTest:(VAR_7)VAR_8 VAR_9:(VAR_10)VAR_9;
/**
恢复出厂设置回调
@param firstPeripheralManager 外设管理对像
@param result 恢复出厂设置结果
*/
- (void)firstPeripheralManager:(VAR_0 *)firstPeripheralManager VAR_12:(VAR_13)VAR_8;
/**
打印设备当前时间
@param firstPeripheralManager 外设管理对像
@param time 时间信息
*/
- (void)firstPeripheralManager:(VAR_0 *)firstPeripheralManager VAR_14:(NCBDate)VAR_15;
/**
打印设备绑定的用户Id
@param firstPeripheralManager 外设管理对像
@param userId 用户id
*/
- (void)firstPeripheralManager:(VAR_0 *)firstPeripheralManager bindUserId:(uint64_t)VAR_16;
/**
打印固件版本号
@param firstPeripheralManager 外设管理对像
@param firmwareVersion 固件版本
*/
- (void)firstPeripheralManager:(VAR_0 *)firstPeripheralManager VAR_17:(NSString *)VAR_17;
@VAR_18
VAR_19
@VAR_20 VAR_0 : NCBPeripheralManager
/// 数据回调
@VAR_21 (VAR_22, VAR_23, nullable) id<VAR_1> VAR_24;
/**
设置时间,绑定登录会自动调用,单纯连接需要手动调用
*/
- (void)VAR_25;
/**
获取历史测量数据
*/
- (void)readHistoryMeasureData;
/**
测试LED是否正常,需要人工选择
*/
- (void)testLedIsNormal;
/**
测试电池电压是否正常
*/
- (void)VAR_26;
/**
测试充电是否正常
*/
- (void)VAR_27;
/**
测试触摸按键是否正常
*/
- (void)VAR_28;
/**
测试OLED是否正常,需要人工选择
*/
- (void)testOLEDIsNormal;
/**
进入休眠模式
*/
- (void)VAR_29;
/**
恢复出厂设置
*/
- (void)restoreFactorySettings;
/**
打印设备当前时间
*/
- (void)VAR_30;
/**
打印设备绑定id
*/
- (void)VAR_31;
/**
打印固件版本
*/
- (void)printDeviceFirmwareVerson;
/**
打印FPGA测量数据
*/
- (void)printFPGAMeasureData;
@CLASS_1
VAR_32
| 0.429075 | {'CLASS_0': 'class', 'VAR_0': 'NCBFirstPerihperalManager', 'VAR_1': 'NCBFirstPerihperalManagerDataDelegate', 'VAR_2': 'NCBPeripheralManagerDataDelegate', 'VAR_3': 'optional', 'VAR_4': '_Nonnull', 'ID_0': 'BOOL', 'VAR_5': 'succeed', 'VAR_6': 'ledTest', 'VAR_7': 'NCBFactoryTestResult', 'VAR_8': 'result', 'VAR_9': 'errorCode', 'VAR_10': 'NCBFactoryTestErrorCode', 'VAR_11': 'touchButtonTest', 'VAR_12': 'didRestoreFactorySettingsResult', 'VAR_13': 'NCBRestoreFactorySettingsResult', 'VAR_14': 'deviceTime', 'VAR_15': 'time', 'VAR_16': 'userId', 'VAR_17': 'firmwareVersion', 'VAR_18': 'end', 'CLASS_1': 'end', 'VAR_19': 'NS_ASSUME_NONNULL_BEGIN', 'VAR_20': 'interface', 'VAR_21': 'property', 'VAR_22': 'nonatomic', 'VAR_23': 'weak', 'VAR_24': 'dataDelegate', 'VAR_25': 'setTime', 'VAR_26': 'testBatteryVoltageIsNormal', 'VAR_27': 'testChargeIsNormal', 'VAR_28': 'testTouchButtonIsNormal', 'VAR_29': 'testEnterDormancyModel', 'VAR_30': 'printDeviceCurrentTime', 'VAR_31': 'printDevieBindId', 'VAR_32': 'NS_ASSUME_NONNULL_END'} |
#pragma once
#include <Node/node.h>
#include <Game/Player/cPlayer.h>
namespace Game
{
namespace UI
{
class cCannonMeter : public Node::node
{
public:
CREATE_H( cCannonMeter, cinder::vec2 contentSize, Player::Team playerTeam, Player::Team myTeam )
{
CREATE( cCannonMeter, contentSize, playerTeam, myTeam );
}
bool init( cinder::vec2 contentSize, Player::Team playerTeam, Player::Team myTeam );
void addPower( int value );
softptr<Node::node> meter;
Player::Team playerTeam;
Player::Team myTeam;
softptr<Node::node> line;
softptr<Node::node> player1;
softptr<Node::node> player2;
softptr<Node::node> player3;
int power = 0;
int GEM_MAX_NUM;
};
}
}
| #pragma once
#include <Node/node.h>
#include <Game/Player/cPlayer.h>
namespace VAR_0
{
namespace UI
{
class cCannonMeter : public VAR_1::VAR_2
{
public:
CREATE_H( cCannonMeter, cinder::VAR_3 VAR_4, Player::Team playerTeam, Player::Team myTeam )
{
CREATE( cCannonMeter, VAR_4, playerTeam, myTeam );
}
bool init( cinder::VAR_3 VAR_4, Player::Team playerTeam, Player::Team myTeam );
void addPower( int value );
softptr<VAR_1::VAR_2> meter;
Player::Team playerTeam;
Player::Team myTeam;
softptr<VAR_1::VAR_2> VAR_5;
softptr<VAR_1::VAR_2> VAR_6;
softptr<VAR_1::VAR_2> VAR_7;
softptr<VAR_1::VAR_2> player3;
int power = 0;
int GEM_MAX_NUM;
};
}
}
| 0.316232 | {'VAR_0': 'Game', 'VAR_1': 'Node', 'VAR_2': 'node', 'VAR_3': 'vec2', 'VAR_4': 'contentSize', 'VAR_5': 'line', 'VAR_6': 'player1', 'VAR_7': 'player2'} |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* lib/krb5/krb/random_str.c - Definition of krb5int_random_string() */
/*
* Copyright (C) 2013 by the Massachusetts Institute of Technology.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "k5-int.h"
/* Utility routine: Creates a readable random string in a fixed size buffer. */
krb5_error_code
krb5int_random_string(krb5_context context, char *string, unsigned int length)
{
static const unsigned char charlist[] =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
krb5_error_code err = 0;
unsigned char *bytes = NULL;
unsigned int bytecount = length - 1;
if (!err) {
bytes = malloc (bytecount);
if (bytes == NULL) { err = ENOMEM; }
}
if (!err) {
krb5_data data;
data.length = bytecount;
data.data = (char *) bytes;
err = krb5_c_random_make_octets (context, &data);
}
if (!err) {
unsigned int i;
for (i = 0; i < bytecount; i++) {
string [i] = charlist[bytes[i] % (sizeof (charlist) - 1)];
}
string[length - 1] = '\0';
}
if (bytes != NULL) { free (bytes); }
return err;
}
| /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* lib/krb5/krb/random_str.c - Definition of krb5int_random_string() */
/*
* Copyright (C) 2013 by the Massachusetts Institute of Technology.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "k5-int.h"
/* Utility routine: Creates a readable random string in a fixed size buffer. */
CLASS_0
krb5int_random_string(krb5_context VAR_0, char *VAR_1, unsigned int VAR_2)
{
static const unsigned char VAR_3[] =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
CLASS_0 err = 0;
unsigned char *bytes = NULL;
unsigned int bytecount = VAR_2 - 1;
if (!err) {
bytes = FUNC_0 (bytecount);
if (bytes == NULL) { err = ENOMEM; }
}
if (!err) {
krb5_data VAR_4;
VAR_4.VAR_2 = bytecount;
VAR_4.VAR_4 = (char *) bytes;
err = FUNC_1 (VAR_0, &VAR_4);
}
if (!err) {
unsigned int i;
for (i = 0; i < bytecount; i++) {
VAR_1 [i] = VAR_3[bytes[i] % (sizeof (VAR_3) - 1)];
}
VAR_1[VAR_2 - 1] = '\0';
}
if (bytes != NULL) { FUNC_2 (bytes); }
return err;
}
| 0.685464 | {'CLASS_0': 'krb5_error_code', 'VAR_0': 'context', 'VAR_1': 'string', 'VAR_2': 'length', 'VAR_3': 'charlist', 'FUNC_0': 'malloc', 'VAR_4': 'data', 'FUNC_1': 'krb5_c_random_make_octets', 'FUNC_2': 'free'} |
/*******************************************************************************
** WeightedEntropy.h
** Part of the mutual information toolbox
**
** Contains functions to calculate the entropy of a single variable H(X),
** the joint entropy of two variables H(X,Y), and the conditional entropy
** H(X|Y), while using a weight vector to modify the calculation.
**
** Author: Adam Pocock
** Created: 20/6/2011
**
** Copyright 2010-2017 Adam Pocock, The University Of Manchester
** www.cs.manchester.ac.uk
**
** This file is part of MIToolbox, licensed under the 3-clause BSD license.
*******************************************************************************/
#ifndef __WeightedEntropy_H
#define __WeightedEntropy_H
#include "MIToolbox/MIToolbox.h"
#include "MIToolbox/CalculateProbability.h"
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
** calculateWeightedEntropy returns the entropy in log base LOG_BASE of dataVector
** H_w(X), weighted by weightVector
**
** length(vectors) == vectorLength otherwise it will segmentation fault
*******************************************************************************/
double calcWeightedEntropy(uint *dataVector, double *weightVector, int vectorLength);
double discAndCalcWeightedEntropy(double *dataVector, double *weightVector, int vectorLength);
/*******************************************************************************
** calculateWeightedJointEntropy returns the entropy in log base LOG_BASE of the joint
** variable of firstVector and secondVector, H_w(XY), weighted by weightVector
**
** length(vectors) == vectorLength otherwise it will segmentation fault
*******************************************************************************/
double calcWeightedJointEntropy(uint *firstVector, uint *secondVector, double *weightVector, int vectorLength);
double discAndCalcWeightedJointEntropy(double *firstVector, double *secondVector, double *weightVector, int vectorLength);
/*******************************************************************************
** calculateWeightedConditionalEntropy returns the entropy in log base LOG_BASE of
** dataVector conditioned on conditionVector, H_w(X|Y), weighted by weightVector
**
** length(vectors) == vectorLength otherwise it will segmentation fault
*******************************************************************************/
double calcWeightedConditionalEntropy(uint *dataVector, uint *conditionVector, double *weightVector, int vectorLength);
double discAndCalcWeightedConditionalEntropy(double *dataVector, double *conditionVector, double *weightVector, int vectorLength);
/*******************************************************************************
** Inner functions which operate on state structs.
*******************************************************************************/
double wEntropy(WeightedProbState state);
double wJointEntropy(WeightedJointProbState state);
double wCondEntropy(WeightedJointProbState state);
#ifdef __cplusplus
}
#endif
#endif
| /*******************************************************************************
** WeightedEntropy.h
** Part of the mutual information toolbox
**
** Contains functions to calculate the entropy of a single variable H(X),
** the joint entropy of two variables H(X,Y), and the conditional entropy
** H(X|Y), while using a weight vector to modify the calculation.
**
** Author: Adam Pocock
** Created: 20/6/2011
**
** Copyright 2010-2017 Adam Pocock, The University Of Manchester
** www.cs.manchester.ac.uk
**
** This file is part of MIToolbox, licensed under the 3-clause BSD license.
*******************************************************************************/
#ifndef VAR_0
#define VAR_0
#include "IMPORT_0"
#include "MIToolbox/CalculateProbability.h"
#ifdef VAR_1
extern "C" {
#endif
/*******************************************************************************
** calculateWeightedEntropy returns the entropy in log base LOG_BASE of dataVector
** H_w(X), weighted by weightVector
**
** length(vectors) == vectorLength otherwise it will segmentation fault
*******************************************************************************/
double calcWeightedEntropy(CLASS_0 *VAR_2, double *weightVector, int VAR_3);
double discAndCalcWeightedEntropy(double *VAR_2, double *weightVector, int VAR_3);
/*******************************************************************************
** calculateWeightedJointEntropy returns the entropy in log base LOG_BASE of the joint
** variable of firstVector and secondVector, H_w(XY), weighted by weightVector
**
** length(vectors) == vectorLength otherwise it will segmentation fault
*******************************************************************************/
double FUNC_0(CLASS_0 *firstVector, CLASS_0 *VAR_4, double *weightVector, int VAR_3);
double discAndCalcWeightedJointEntropy(double *firstVector, double *VAR_4, double *weightVector, int VAR_3);
/*******************************************************************************
** calculateWeightedConditionalEntropy returns the entropy in log base LOG_BASE of
** dataVector conditioned on conditionVector, H_w(X|Y), weighted by weightVector
**
** length(vectors) == vectorLength otherwise it will segmentation fault
*******************************************************************************/
double calcWeightedConditionalEntropy(CLASS_0 *VAR_2, CLASS_0 *VAR_5, double *weightVector, int VAR_3);
double FUNC_1(double *VAR_2, double *VAR_5, double *weightVector, int VAR_3);
/*******************************************************************************
** Inner functions which operate on state structs.
*******************************************************************************/
double wEntropy(CLASS_1 state);
double FUNC_2(WeightedJointProbState state);
double FUNC_3(WeightedJointProbState state);
#ifdef VAR_1
}
#endif
#endif
| 0.595834 | {'VAR_0': '__WeightedEntropy_H', 'IMPORT_0': 'MIToolbox/MIToolbox.h', 'VAR_1': '__cplusplus', 'CLASS_0': 'uint', 'VAR_2': 'dataVector', 'VAR_3': 'vectorLength', 'FUNC_0': 'calcWeightedJointEntropy', 'VAR_4': 'secondVector', 'VAR_5': 'conditionVector', 'FUNC_1': 'discAndCalcWeightedConditionalEntropy', 'CLASS_1': 'WeightedProbState', 'FUNC_2': 'wJointEntropy', 'FUNC_3': 'wCondEntropy'} |
/*
* Copyright © 2021 Michał 'Griwes' Dominiak
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "../../../util/integer_types.h"
#include "../../cpu.h"
namespace kernel::acpi
{
void initialize(std::size_t revision, phys_addr_t acpi_root);
struct madt_result
{
std::size_t core_count;
phys_addr_t lapic_base;
};
madt_result parse_madt(arch::cpu::core * cores_storage, std::size_t core_count);
struct hpet_result
{
phys_addr_t base;
std::uint16_t min_tick;
};
hpet_result parse_hpet();
}
| /*
* Copyright © 2021 Michał 'Griwes' Dominiak
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "../../../util/integer_types.h"
#include "IMPORT_0"
namespace kernel::VAR_0
{
void FUNC_0(std::size_t revision, phys_addr_t VAR_1);
struct madt_result
{
std::size_t core_count;
phys_addr_t lapic_base;
};
madt_result parse_madt(arch::cpu::core * cores_storage, std::size_t core_count);
struct hpet_result
{
phys_addr_t base;
std::uint16_t min_tick;
};
hpet_result FUNC_1();
}
| 0.371679 | {'IMPORT_0': '../../cpu.h', 'VAR_0': 'acpi', 'FUNC_0': 'initialize', 'VAR_1': 'acpi_root', 'FUNC_1': 'parse_hpet'} |
/*
* i2cmasterdrv.c
*
* Created: 28/07/2021 19:25:41
* Author: jerem
*/
#include "i2cmasterdrv.h"
void InitialiseI2C()
{
/* Disable TWI */
//PRR &= ~(1 << PRTWI);
TWCR = 0;
/* SCL bitrate = F_CPU / (16 + 2 * TWBR * TWPS value) */
/* Configured bit rate is 100.000kHz, based on CPU frequency 8.000MHz */
TWBR = 0x40; /* SCL bit rate: 100.000kHZ before prescaler 0X20 default */
TWSR &= ~(1<<TWPS0); /* SCL prescaler: 1, effective bit-rate = 100.000kHz */
TWSR &= ~(1<<TWPS1);
TWCR |= CLEAR_I2C_INT_FLAG | ENABLE_I2C;
TWCR &= ~(ENABLE_I2C_INT);
TWCR &= ~(ENABLE_ACK_GEN);
}
i2cstat_t StartI2CWrite(uint8_t addr)
{
uint8_t addrBuff = addr;
addrBuff = (addrBuff << 1) | I2C_WRITE;
TWCR |= CLEAR_I2C_INT_FLAG | START_I2C | ENABLE_I2C;
while(!(TWCR & (1<<TWINT)));
if(I2C_STAT != START_OK) return START_ERROR;
//Print(START_SUCCESSFUL);
TWDR = addrBuff;
TWCR &= ~(1<<TWSTA);
TWCR |= (1<<TWINT) | (1<<TWEN);
while(!(BUSY_I2C));
if(I2C_STAT != SLA_W_ACK) return ADDR_NACK;
//Print(ADDR_ACK);
return ADDR_ACK;
}
i2cstat_t StopI2C()
{
TWCR |= CLEAR_I2C_INT_FLAG | ENABLE_I2C | STOP_I2C;
return STOP_DONE;
}
i2cstat_t WriteI2Cbyte(uint8_t addr, uint8_t data)
{
i2cstat_t status;
status = StartI2CWrite(addr);
if (status != ADDR_ACK) return status;
//Print(status);
TWDR = data;
TWCR |= CLEAR_I2C_INT_FLAG | ENABLE_I2C;
while(!(BUSY_I2C));
if (I2C_STAT != DATA_ACK)
{
StopI2C();
return NACK_DATA;
}
//Print(DATA_ACK)
StopI2C();
return ACK_DATA;
}
| /*
* i2cmasterdrv.c
*
* Created: 28/07/2021 19:25:41
* Author: jerem
*/
#include "IMPORT_0"
void FUNC_0()
{
/* Disable TWI */
//PRR &= ~(1 << PRTWI);
VAR_0 = 0;
/* SCL bitrate = F_CPU / (16 + 2 * TWBR * TWPS value) */
/* Configured bit rate is 100.000kHz, based on CPU frequency 8.000MHz */
VAR_1 = 0x40; /* SCL bit rate: 100.000kHZ before prescaler 0X20 default */
VAR_2 &= ~(1<<VAR_3); /* SCL prescaler: 1, effective bit-rate = 100.000kHz */
VAR_2 &= ~(1<<VAR_4);
VAR_0 |= VAR_5 | VAR_6;
VAR_0 &= ~(VAR_7);
VAR_0 &= ~(VAR_8);
}
CLASS_0 FUNC_1(uint8_t VAR_9)
{
uint8_t VAR_10 = VAR_9;
VAR_10 = (VAR_10 << 1) | VAR_11;
VAR_0 |= VAR_5 | VAR_12 | VAR_6;
while(!(VAR_0 & (1<<VAR_13)));
if(VAR_14 != VAR_15) return VAR_16;
//Print(START_SUCCESSFUL);
VAR_17 = VAR_10;
VAR_0 &= ~(1<<VAR_18);
VAR_0 |= (1<<VAR_13) | (1<<VAR_19);
while(!(VAR_20));
if(VAR_14 != VAR_21) return VAR_22;
//Print(ADDR_ACK);
return VAR_23;
}
CLASS_0 FUNC_2()
{
VAR_0 |= VAR_5 | VAR_6 | VAR_24;
return STOP_DONE;
}
CLASS_0 FUNC_3(uint8_t VAR_9, uint8_t VAR_25)
{
CLASS_0 VAR_26;
VAR_26 = FUNC_1(VAR_9);
if (VAR_26 != VAR_23) return VAR_26;
//Print(status);
VAR_17 = VAR_25;
VAR_0 |= VAR_5 | VAR_6;
while(!(VAR_20));
if (VAR_14 != VAR_27)
{
FUNC_2();
return VAR_28;
}
//Print(DATA_ACK)
FUNC_2();
return VAR_29;
}
| 0.985054 | {'IMPORT_0': 'i2cmasterdrv.h', 'FUNC_0': 'InitialiseI2C', 'VAR_0': 'TWCR', 'VAR_1': 'TWBR', 'VAR_2': 'TWSR', 'VAR_3': 'TWPS0', 'VAR_4': 'TWPS1', 'VAR_5': 'CLEAR_I2C_INT_FLAG', 'VAR_6': 'ENABLE_I2C', 'VAR_7': 'ENABLE_I2C_INT', 'VAR_8': 'ENABLE_ACK_GEN', 'CLASS_0': 'i2cstat_t', 'FUNC_1': 'StartI2CWrite', 'VAR_9': 'addr', 'VAR_10': 'addrBuff', 'VAR_11': 'I2C_WRITE', 'VAR_12': 'START_I2C', 'VAR_13': 'TWINT', 'VAR_14': 'I2C_STAT', 'VAR_15': 'START_OK', 'VAR_16': 'START_ERROR', 'VAR_17': 'TWDR', 'VAR_18': 'TWSTA', 'VAR_19': 'TWEN', 'VAR_20': 'BUSY_I2C', 'VAR_21': 'SLA_W_ACK', 'VAR_22': 'ADDR_NACK', 'VAR_23': 'ADDR_ACK', 'FUNC_2': 'StopI2C', 'VAR_24': 'STOP_I2C', 'FUNC_3': 'WriteI2Cbyte', 'VAR_25': 'data', 'VAR_26': 'status', 'VAR_27': 'DATA_ACK', 'VAR_28': 'NACK_DATA', 'VAR_29': 'ACK_DATA'} |
/* src/interfaces/ecpg/ecpglib/extern.h */
#ifndef _ECPG_LIB_EXTERN_H
#define _ECPG_LIB_EXTERN_H
#include "libpq-fe.h"
#include "sqlca.h"
#include "sqlda-native.h"
#include "sqlda-compat.h"
#include "ecpg_config.h"
#ifndef CHAR_BIT
#include <limits.h>
#endif
enum COMPAT_MODE
{
ECPG_COMPAT_PGSQL = 0, ECPG_COMPAT_INFORMIX, ECPG_COMPAT_INFORMIX_SE
};
extern bool ecpg_internal_regression_mode;
#define INFORMIX_MODE(X) ((X) == ECPG_COMPAT_INFORMIX || (X) == ECPG_COMPAT_INFORMIX_SE)
enum ARRAY_TYPE
{
ECPG_ARRAY_ERROR, ECPG_ARRAY_NOT_SET, ECPG_ARRAY_ARRAY, ECPG_ARRAY_VECTOR, ECPG_ARRAY_NONE
};
#define ECPG_IS_ARRAY(X) ((X) == ECPG_ARRAY_ARRAY || (X) == ECPG_ARRAY_VECTOR)
/* A generic varchar type. */
struct ECPGgeneric_varchar
{
int len;
char arr[FLEXIBLE_ARRAY_MEMBER];
};
/*
* type information cache
*/
struct ECPGtype_information_cache
{
struct ECPGtype_information_cache *next;
int oid;
enum ARRAY_TYPE isarray;
};
/* structure to store one statement */
struct statement
{
int lineno;
char *command;
char *name;
struct connection *connection;
enum COMPAT_MODE compat;
bool force_indicator;
enum ECPG_statement_type statement_type;
bool questionmarks;
struct variable *inlist;
struct variable *outlist;
char *oldlocale;
int nparams;
char **paramvalues;
PGresult *results;
};
/* structure to store prepared statements for a connection */
struct prepared_statement
{
char *name;
bool prepared;
struct statement *stmt;
struct prepared_statement *next;
};
/* structure to store connections */
struct connection
{
char *name;
PGconn *connection;
bool autocommit;
struct ECPGtype_information_cache *cache_head;
struct prepared_statement *prep_stmts;
struct connection *next;
};
/* structure to store descriptors */
struct descriptor
{
char *name;
PGresult *result;
struct descriptor *next;
int count;
struct descriptor_item *items;
};
struct descriptor_item
{
int num;
char *data;
int indicator;
int length;
int precision;
int scale;
int type;
struct descriptor_item *next;
};
struct variable
{
enum ECPGttype type;
void *value;
void *pointer;
long varcharsize;
long arrsize;
long offset;
enum ECPGttype ind_type;
void *ind_value;
void *ind_pointer;
long ind_varcharsize;
long ind_arrsize;
long ind_offset;
struct variable *next;
};
struct var_list
{
int number;
void *pointer;
struct var_list *next;
};
extern struct var_list *ivlist;
/* Here are some methods used by the lib. */
bool ecpg_add_mem(void *ptr, int lineno);
bool ecpg_get_data(const PGresult *, int, int, int, enum ECPGttype type,
enum ECPGttype, char *, char *, long, long, long,
enum ARRAY_TYPE, enum COMPAT_MODE, bool);
#ifdef ENABLE_THREAD_SAFETY
void ecpg_pthreads_init(void);
#endif
struct connection *ecpg_get_connection(const char *);
char *ecpg_alloc(long, int);
char *ecpg_auto_alloc(long, int);
char *ecpg_realloc(void *, long, int);
void ecpg_free(void *);
bool ecpg_init(const struct connection *, const char *, const int);
char *ecpg_strdup(const char *, int);
const char *ecpg_type_name(enum ECPGttype);
int ecpg_dynamic_type(Oid);
int sqlda_dynamic_type(Oid, enum COMPAT_MODE);
void ecpg_free_auto_mem(void);
void ecpg_clear_auto_mem(void);
struct descriptor *ecpggetdescp(int, char *);
struct descriptor *ecpg_find_desc(int line, const char *name);
struct prepared_statement *ecpg_find_prepared_statement(const char *,
struct connection *, struct prepared_statement **);
bool ecpg_store_result(const PGresult *results, int act_field,
const struct statement *stmt, struct variable *var);
bool ecpg_store_input(const int, const bool, const struct variable *, char **, bool);
void ecpg_free_params(struct statement *stmt, bool print);
bool ecpg_do_prologue(int, const int, const int, const char *, const bool,
enum ECPG_statement_type, const char *, va_list,
struct statement **);
bool ecpg_build_params(struct statement *);
bool ecpg_autostart_transaction(struct statement *stmt);
bool ecpg_execute(struct statement *stmt);
bool ecpg_process_output(struct statement *, bool);
void ecpg_do_epilogue(struct statement *);
bool ecpg_do(const int, const int, const int, const char *, const bool,
const int, const char *, va_list);
bool ecpg_check_PQresult(PGresult *, int, PGconn *, enum COMPAT_MODE);
void ecpg_raise(int line, int code, const char *sqlstate, const char *str);
void ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat);
char *ecpg_prepared(const char *, struct connection *);
bool ecpg_deallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection *conn);
void ecpg_log(const char *format,...) pg_attribute_printf(1, 2);
bool ecpg_auto_prepare(int, const char *, const int, char **, const char *);
void ecpg_init_sqlca(struct sqlca_t *sqlca);
struct sqlda_compat *ecpg_build_compat_sqlda(int, PGresult *, int, enum COMPAT_MODE);
void ecpg_set_compat_sqlda(int, struct sqlda_compat **, const PGresult *, int, enum COMPAT_MODE);
struct sqlda_struct *ecpg_build_native_sqlda(int, PGresult *, int, enum COMPAT_MODE);
void ecpg_set_native_sqlda(int, struct sqlda_struct **, const PGresult *, int, enum COMPAT_MODE);
/* SQLSTATE values generated or processed by ecpglib (intentionally
* not exported -- users should refer to the codes directly) */
#define ECPG_SQLSTATE_NO_DATA "02000"
#define ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS "07001"
#define ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_TARGETS "07002"
#define ECPG_SQLSTATE_RESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION "07006"
#define ECPG_SQLSTATE_INVALID_DESCRIPTOR_INDEX "07009"
#define ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION "08001"
#define ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST "08003"
#define ECPG_SQLSTATE_TRANSACTION_RESOLUTION_UNKNOWN "08007"
#define ECPG_SQLSTATE_CARDINALITY_VIOLATION "21000"
#define ECPG_SQLSTATE_NULL_VALUE_NO_INDICATOR_PARAMETER "22002"
#define ECPG_SQLSTATE_ACTIVE_SQL_TRANSACTION "25001"
#define ECPG_SQLSTATE_NO_ACTIVE_SQL_TRANSACTION "25P01"
#define ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME "26000"
#define ECPG_SQLSTATE_INVALID_SQL_DESCRIPTOR_NAME "33000"
#define ECPG_SQLSTATE_INVALID_CURSOR_NAME "34000"
#define ECPG_SQLSTATE_SYNTAX_ERROR "42601"
#define ECPG_SQLSTATE_DATATYPE_MISMATCH "42804"
#define ECPG_SQLSTATE_DUPLICATE_CURSOR "42P03"
/* implementation-defined internal errors of ecpg */
#define ECPG_SQLSTATE_ECPG_INTERNAL_ERROR "YE000"
#define ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY "YE001"
#endif /* _ECPG_LIB_EXTERN_H */
| /* src/interfaces/ecpg/ecpglib/extern.h */
#ifndef VAR_0
#define VAR_0
#include "IMPORT_0"
#include "IMPORT_1"
#include "sqlda-native.h"
#include "IMPORT_2"
#include "IMPORT_3"
#ifndef VAR_1
#include <IMPORT_4>
#endif
enum CLASS_0
{
VAR_2 = 0, VAR_3, ECPG_COMPAT_INFORMIX_SE
};
extern bool VAR_4;
#define FUNC_0(VAR_5) ((X) == ECPG_COMPAT_INFORMIX || (X) == ECPG_COMPAT_INFORMIX_SE)
enum ARRAY_TYPE
{
VAR_6, VAR_7, ECPG_ARRAY_ARRAY, VAR_8, VAR_9
};
#define FUNC_1(VAR_5) ((X) == ECPG_ARRAY_ARRAY || (X) == ECPG_ARRAY_VECTOR)
/* A generic varchar type. */
struct CLASS_1
{
int VAR_10;
char VAR_11[VAR_12];
};
/*
* type information cache
*/
struct CLASS_2
{
struct CLASS_2 *VAR_13;
int VAR_14;
enum ARRAY_TYPE isarray;
};
/* structure to store one statement */
struct CLASS_3
{
int lineno;
char *VAR_15;
char *VAR_16;
struct connection *connection;
enum CLASS_0 compat;
bool VAR_17;
enum CLASS_4 statement_type;
bool questionmarks;
struct CLASS_5 *VAR_18;
struct CLASS_5 *VAR_19;
char *oldlocale;
int VAR_20;
char **VAR_21;
CLASS_6 *VAR_22;
};
/* structure to store prepared statements for a connection */
struct CLASS_7
{
char *VAR_16;
bool prepared;
struct CLASS_3 *VAR_23;
struct CLASS_7 *VAR_13;
};
/* structure to store connections */
struct connection
{
char *VAR_16;
CLASS_8 *connection;
bool VAR_24;
struct CLASS_2 *VAR_25;
struct CLASS_7 *VAR_26;
struct connection *VAR_13;
};
/* structure to store descriptors */
struct descriptor
{
char *VAR_16;
CLASS_6 *result;
struct descriptor *VAR_13;
int count;
struct descriptor_item *VAR_27;
};
struct descriptor_item
{
int VAR_28;
char *VAR_29;
int indicator;
int VAR_30;
int VAR_31;
int scale;
int type;
struct descriptor_item *VAR_13;
};
struct CLASS_5
{
enum ECPGttype type;
void *VAR_32;
void *VAR_33;
long VAR_34;
long VAR_35;
long offset;
enum ECPGttype VAR_36;
void *VAR_37;
void *ind_pointer;
long VAR_38;
long VAR_39;
long VAR_40;
struct CLASS_5 *VAR_13;
};
struct var_list
{
int VAR_41;
void *VAR_33;
struct var_list *VAR_13;
};
extern struct var_list *VAR_42;
/* Here are some methods used by the lib. */
bool ecpg_add_mem(void *VAR_43, int lineno);
bool FUNC_2(const CLASS_6 *, int, int, int, enum ECPGttype type,
enum ECPGttype, char *, char *, long, long, long,
enum ARRAY_TYPE, enum CLASS_0, bool);
#ifdef VAR_44
void FUNC_3(void);
#endif
struct connection *ecpg_get_connection(const char *);
char *FUNC_4(long, int);
char *FUNC_5(long, int);
char *FUNC_6(void *, long, int);
void FUNC_7(void *);
bool FUNC_8(const struct connection *, const char *, const int);
char *FUNC_9(const char *, int);
const char *FUNC_10(enum ECPGttype);
int FUNC_11(CLASS_9);
int FUNC_12(CLASS_9, enum CLASS_0);
void FUNC_13(void);
void FUNC_14(void);
struct descriptor *FUNC_15(int, char *);
struct descriptor *FUNC_16(int VAR_45, const char *VAR_16);
struct CLASS_7 *FUNC_17(const char *,
struct connection *, struct CLASS_7 **);
bool FUNC_18(const CLASS_6 *VAR_22, int VAR_46,
const struct CLASS_3 *VAR_23, struct CLASS_5 *VAR_47);
bool FUNC_19(const int, const bool, const struct CLASS_5 *, char **, bool);
void FUNC_20(struct CLASS_3 *VAR_23, bool VAR_48);
bool FUNC_21(int, const int, const int, const char *, const bool,
enum CLASS_4, const char *, CLASS_10,
struct CLASS_3 **);
bool FUNC_22(struct CLASS_3 *);
bool FUNC_23(struct CLASS_3 *VAR_23);
bool FUNC_24(struct CLASS_3 *VAR_23);
bool ecpg_process_output(struct CLASS_3 *, bool);
void ecpg_do_epilogue(struct CLASS_3 *);
bool FUNC_25(const int, const int, const int, const char *, const bool,
const int, const char *, CLASS_10);
bool FUNC_26(CLASS_6 *, int, CLASS_8 *, enum CLASS_0);
void FUNC_27(int VAR_45, int VAR_49, const char *VAR_50, const char *str);
void FUNC_28(int VAR_45, CLASS_6 *result, CLASS_8 *VAR_51, int compat);
char *FUNC_29(const char *, struct connection *);
bool FUNC_30(int lineno, enum CLASS_0 VAR_52, struct connection *VAR_51);
void FUNC_31(const char *VAR_53,...) FUNC_32(1, 2);
bool FUNC_33(int, const char *, const int, char **, const char *);
void FUNC_34(struct sqlca_t *VAR_54);
struct CLASS_11 *FUNC_35(int, CLASS_6 *, int, enum CLASS_0);
void FUNC_36(int, struct CLASS_11 **, const CLASS_6 *, int, enum CLASS_0);
struct sqlda_struct *FUNC_37(int, CLASS_6 *, int, enum CLASS_0);
void ecpg_set_native_sqlda(int, struct sqlda_struct **, const CLASS_6 *, int, enum CLASS_0);
/* SQLSTATE values generated or processed by ecpglib (intentionally
* not exported -- users should refer to the codes directly) */
#define ECPG_SQLSTATE_NO_DATA "02000"
#define VAR_55 "07001"
#define VAR_56 "07002"
#define VAR_57 "07006"
#define VAR_58 "07009"
#define VAR_59 "08001"
#define VAR_60 "08003"
#define VAR_61 "08007"
#define ECPG_SQLSTATE_CARDINALITY_VIOLATION "21000"
#define VAR_62 "22002"
#define VAR_63 "25001"
#define VAR_64 "25P01"
#define VAR_65 "26000"
#define VAR_66 "33000"
#define ECPG_SQLSTATE_INVALID_CURSOR_NAME "34000"
#define VAR_67 "42601"
#define VAR_68 "42804"
#define VAR_69 "42P03"
/* implementation-defined internal errors of ecpg */
#define VAR_70 "YE000"
#define VAR_71 "YE001"
#endif /* _ECPG_LIB_EXTERN_H */
| 0.822038 | {'VAR_0': '_ECPG_LIB_EXTERN_H', 'IMPORT_0': 'libpq-fe.h', 'IMPORT_1': 'sqlca.h', 'IMPORT_2': 'sqlda-compat.h', 'IMPORT_3': 'ecpg_config.h', 'VAR_1': 'CHAR_BIT', 'IMPORT_4': 'limits.h', 'CLASS_0': 'COMPAT_MODE', 'VAR_2': 'ECPG_COMPAT_PGSQL', 'VAR_3': 'ECPG_COMPAT_INFORMIX', 'VAR_4': 'ecpg_internal_regression_mode', 'FUNC_0': 'INFORMIX_MODE', 'VAR_5': 'X', 'VAR_6': 'ECPG_ARRAY_ERROR', 'VAR_7': 'ECPG_ARRAY_NOT_SET', 'VAR_8': 'ECPG_ARRAY_VECTOR', 'VAR_9': 'ECPG_ARRAY_NONE', 'FUNC_1': 'ECPG_IS_ARRAY', 'CLASS_1': 'ECPGgeneric_varchar', 'VAR_10': 'len', 'VAR_11': 'arr', 'VAR_12': 'FLEXIBLE_ARRAY_MEMBER', 'CLASS_2': 'ECPGtype_information_cache', 'VAR_13': 'next', 'VAR_14': 'oid', 'CLASS_3': 'statement', 'VAR_15': 'command', 'VAR_16': 'name', 'VAR_17': 'force_indicator', 'CLASS_4': 'ECPG_statement_type', 'CLASS_5': 'variable', 'VAR_18': 'inlist', 'VAR_19': 'outlist', 'VAR_20': 'nparams', 'VAR_21': 'paramvalues', 'CLASS_6': 'PGresult', 'VAR_22': 'results', 'CLASS_7': 'prepared_statement', 'VAR_23': 'stmt', 'CLASS_8': 'PGconn', 'VAR_24': 'autocommit', 'VAR_25': 'cache_head', 'VAR_26': 'prep_stmts', 'VAR_27': 'items', 'VAR_28': 'num', 'VAR_29': 'data', 'VAR_30': 'length', 'VAR_31': 'precision', 'VAR_32': 'value', 'VAR_33': 'pointer', 'VAR_34': 'varcharsize', 'VAR_35': 'arrsize', 'VAR_36': 'ind_type', 'VAR_37': 'ind_value', 'VAR_38': 'ind_varcharsize', 'VAR_39': 'ind_arrsize', 'VAR_40': 'ind_offset', 'VAR_41': 'number', 'VAR_42': 'ivlist', 'VAR_43': 'ptr', 'FUNC_2': 'ecpg_get_data', 'VAR_44': 'ENABLE_THREAD_SAFETY', 'FUNC_3': 'ecpg_pthreads_init', 'FUNC_4': 'ecpg_alloc', 'FUNC_5': 'ecpg_auto_alloc', 'FUNC_6': 'ecpg_realloc', 'FUNC_7': 'ecpg_free', 'FUNC_8': 'ecpg_init', 'FUNC_9': 'ecpg_strdup', 'FUNC_10': 'ecpg_type_name', 'FUNC_11': 'ecpg_dynamic_type', 'CLASS_9': 'Oid', 'FUNC_12': 'sqlda_dynamic_type', 'FUNC_13': 'ecpg_free_auto_mem', 'FUNC_14': 'ecpg_clear_auto_mem', 'FUNC_15': 'ecpggetdescp', 'FUNC_16': 'ecpg_find_desc', 'VAR_45': 'line', 'FUNC_17': 'ecpg_find_prepared_statement', 'FUNC_18': 'ecpg_store_result', 'VAR_46': 'act_field', 'VAR_47': 'var', 'FUNC_19': 'ecpg_store_input', 'FUNC_20': 'ecpg_free_params', 'VAR_48': 'print', 'FUNC_21': 'ecpg_do_prologue', 'CLASS_10': 'va_list', 'FUNC_22': 'ecpg_build_params', 'FUNC_23': 'ecpg_autostart_transaction', 'FUNC_24': 'ecpg_execute', 'FUNC_25': 'ecpg_do', 'FUNC_26': 'ecpg_check_PQresult', 'FUNC_27': 'ecpg_raise', 'VAR_49': 'code', 'VAR_50': 'sqlstate', 'FUNC_28': 'ecpg_raise_backend', 'VAR_51': 'conn', 'FUNC_29': 'ecpg_prepared', 'FUNC_30': 'ecpg_deallocate_all_conn', 'VAR_52': 'c', 'FUNC_31': 'ecpg_log', 'VAR_53': 'format', 'FUNC_32': 'pg_attribute_printf', 'FUNC_33': 'ecpg_auto_prepare', 'FUNC_34': 'ecpg_init_sqlca', 'VAR_54': 'sqlca', 'CLASS_11': 'sqlda_compat', 'FUNC_35': 'ecpg_build_compat_sqlda', 'FUNC_36': 'ecpg_set_compat_sqlda', 'FUNC_37': 'ecpg_build_native_sqlda', 'VAR_55': 'ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_PARAMETERS', 'VAR_56': 'ECPG_SQLSTATE_USING_CLAUSE_DOES_NOT_MATCH_TARGETS', 'VAR_57': 'ECPG_SQLSTATE_RESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION', 'VAR_58': 'ECPG_SQLSTATE_INVALID_DESCRIPTOR_INDEX', 'VAR_59': 'ECPG_SQLSTATE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION', 'VAR_60': 'ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST', 'VAR_61': 'ECPG_SQLSTATE_TRANSACTION_RESOLUTION_UNKNOWN', 'VAR_62': 'ECPG_SQLSTATE_NULL_VALUE_NO_INDICATOR_PARAMETER', 'VAR_63': 'ECPG_SQLSTATE_ACTIVE_SQL_TRANSACTION', 'VAR_64': 'ECPG_SQLSTATE_NO_ACTIVE_SQL_TRANSACTION', 'VAR_65': 'ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME', 'VAR_66': 'ECPG_SQLSTATE_INVALID_SQL_DESCRIPTOR_NAME', 'VAR_67': 'ECPG_SQLSTATE_SYNTAX_ERROR', 'VAR_68': 'ECPG_SQLSTATE_DATATYPE_MISMATCH', 'VAR_69': 'ECPG_SQLSTATE_DUPLICATE_CURSOR', 'VAR_70': 'ECPG_SQLSTATE_ECPG_INTERNAL_ERROR', 'VAR_71': 'ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY'} |
// TerrainMesh.h
// Generates a plane mesh based on resolution, which can be manipulated using a heightmap.
// Uses "quilt" pattern to build a series of quads across the mesh.
// Adapted from a combination of the CMP301 plane mesh, the CMP301 quad mesh, and the Rastertek terrain mesh provided in the terrain generation tutorials
#ifndef _TERRAINMESH_H_
#define _TERRAINMESH_H_
#include "../DXFramework/BaseMesh.h"
#include "ImprovedNoise.h"
#include "SimplexNoise.h"
class TerrainMesh : public BaseMesh
{
struct HeightMapType
{
float x, y, z;
float nx, ny, nz;
};
struct VectorType
{
float x, y, z;
};
public:
TerrainMesh(ID3D11Device* device, ID3D11DeviceContext* deviceContext, ImprovedNoise* perlinNoise, SimplexNoise* simplexNoise, int resolution = 100);
~TerrainMesh();
// Function for generating the heightmap using fractional Brownian motion alongside Perlin noise or Simplex noise
void GenerateHeightMap(float offsetX, float offsetZ, float frequency, float amplitude, bool ridged, bool simplex,
int octaves, float persistence, float offsetY);
// Function for smoothing out generated terrain within given height bounds
void SmoothingFunction(float smoothingWeight, float upperBound, float lowerBound);
// Thermal erosion simulates material breaking loose and sliding down slopes over time
// Results in generally smoother, flatter terrain
// Reference implementation: http://web.mit.edu/cesium/Public/terrain.pdf
void ThermalErosion(int erosionIterations);
// Hydraulic erosion simulates the effects of water on terrain over time by depositing droplets over terrain
// Results in ridged, rough terrain
// Reference implementation: https://github.com/vogtb/terrain-map/blob/master/landmap.js
void HydraulicErosion(float carryingCapacity, float depositionSpeed, int iterations, int drops, float persistence);
void initBuffers(ID3D11Device* device);
bool CalculateNormals();
private:
// Function for depositing sediment from the thermal erosion algorithm
float DepositSediment(float c, float maxDiff, float talus, float distance, float totalDiff);
int resolution;
HeightMapType* heightMap;
// Pointers to the noise generation objects
ImprovedNoise* perlinNoiseGen;
SimplexNoise* simplexNoiseGen;
};
#endif | // TerrainMesh.h
// Generates a plane mesh based on resolution, which can be manipulated using a heightmap.
// Uses "quilt" pattern to build a series of quads across the mesh.
// Adapted from a combination of the CMP301 plane mesh, the CMP301 quad mesh, and the Rastertek terrain mesh provided in the terrain generation tutorials
#ifndef VAR_0
#define VAR_0
#include "IMPORT_0"
#include "IMPORT_1"
#include "IMPORT_2"
CLASS_0 VAR_1 : VAR_2 VAR_3
{
struct CLASS_1
{
float VAR_4, VAR_5, VAR_6;
float VAR_7, VAR_8, VAR_9;
};
struct CLASS_2
{
float VAR_4, VAR_5, VAR_6;
};
public:
FUNC_0(VAR_10* VAR_11, VAR_12* VAR_13, VAR_14* VAR_15, VAR_16* VAR_17, VAR_18 VAR_19 = 100);
~FUNC_0();
// Function for generating the heightmap using fractional Brownian motion alongside Perlin noise or Simplex noise
void FUNC_1(float VAR_20, float VAR_21, float VAR_22, float VAR_23, bool VAR_24, bool VAR_25,
int VAR_26, float VAR_27, float VAR_28);
// Function for smoothing out generated terrain within given height bounds
void FUNC_2(float VAR_29, float VAR_30, float VAR_31);
// Thermal erosion simulates material breaking loose and sliding down slopes over time
// Results in generally smoother, flatter terrain
// Reference implementation: http://web.mit.edu/cesium/Public/terrain.pdf
void FUNC_3(int VAR_32);
// Hydraulic erosion simulates the effects of water on terrain over time by depositing droplets over terrain
// Results in ridged, rough terrain
// Reference implementation: https://github.com/vogtb/terrain-map/blob/master/landmap.js
void FUNC_4(float VAR_33, float VAR_34, int VAR_35, int VAR_36, float VAR_27);
void FUNC_5(CLASS_3* VAR_11);
bool FUNC_6();
private:
// Function for depositing sediment from the thermal erosion algorithm
VAR_37 FUNC_7(VAR_37 VAR_38, VAR_37 VAR_39, VAR_37 VAR_40, VAR_37 VAR_41, VAR_37 VAR_42);
int VAR_19;
CLASS_1* VAR_43;
// Pointers to the noise generation objects
CLASS_4* VAR_44;
CLASS_5* VAR_45;
};
#endif | 0.974255 | {'VAR_0': '_TERRAINMESH_H_', 'IMPORT_0': '../DXFramework/BaseMesh.h', 'IMPORT_1': 'ImprovedNoise.h', 'IMPORT_2': 'SimplexNoise.h', 'CLASS_0': 'class', 'VAR_1': 'TerrainMesh', 'FUNC_0': 'TerrainMesh', 'VAR_2': 'public', 'VAR_3': 'BaseMesh', 'CLASS_1': 'HeightMapType', 'VAR_4': 'x', 'VAR_5': 'y', 'VAR_6': 'z', 'VAR_7': 'nx', 'VAR_8': 'ny', 'VAR_9': 'nz', 'CLASS_2': 'VectorType', 'VAR_10': 'ID3D11Device', 'CLASS_3': 'ID3D11Device', 'VAR_11': 'device', 'VAR_12': 'ID3D11DeviceContext', 'VAR_13': 'deviceContext', 'VAR_14': 'ImprovedNoise', 'CLASS_4': 'ImprovedNoise', 'VAR_15': 'perlinNoise', 'VAR_16': 'SimplexNoise', 'CLASS_5': 'SimplexNoise', 'VAR_17': 'simplexNoise', 'VAR_18': 'int', 'VAR_19': 'resolution', 'FUNC_1': 'GenerateHeightMap', 'VAR_20': 'offsetX', 'VAR_21': 'offsetZ', 'VAR_22': 'frequency', 'VAR_23': 'amplitude', 'VAR_24': 'ridged', 'VAR_25': 'simplex', 'VAR_26': 'octaves', 'VAR_27': 'persistence', 'VAR_28': 'offsetY', 'FUNC_2': 'SmoothingFunction', 'VAR_29': 'smoothingWeight', 'VAR_30': 'upperBound', 'VAR_31': 'lowerBound', 'FUNC_3': 'ThermalErosion', 'VAR_32': 'erosionIterations', 'FUNC_4': 'HydraulicErosion', 'VAR_33': 'carryingCapacity', 'VAR_34': 'depositionSpeed', 'VAR_35': 'iterations', 'VAR_36': 'drops', 'FUNC_5': 'initBuffers', 'FUNC_6': 'CalculateNormals', 'VAR_37': 'float', 'FUNC_7': 'DepositSediment', 'VAR_38': 'c', 'VAR_39': 'maxDiff', 'VAR_40': 'talus', 'VAR_41': 'distance', 'VAR_42': 'totalDiff', 'VAR_43': 'heightMap', 'VAR_44': 'perlinNoiseGen', 'VAR_45': 'simplexNoiseGen'} |
//
// UIView+BorderLine.h
// CYOCFramework
//
// Created by yanyan on 2017/9/29.
// Copyright © 2017年 yanyan. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_OPTIONS(NSUInteger, UIBorderSideType) {
UIBorderSideTypeAll = 0,
UIBorderSideTypeTop = 1 << 0,
UIBorderSideTypeBottom = 1 << 1,
UIBorderSideTypeLeft = 1 << 2,
UIBorderSideTypeRight = 1 << 3,
};
@interface UIView(BorderLine)
- (UIView *)borderForColor:(UIColor *)color borderWidth:(CGFloat)borderWidth borderType:(UIBorderSideType)borderType;
//在 view 里面
- (UIView *)inBorderForColor:(UIColor *)color borderWidth:(CGFloat)borderWidth borderType:(UIBorderSideType)borderType;
@end
| //
// UIView+BorderLine.h
// CYOCFramework
//
// Created by yanyan on 2017/9/29.
// Copyright © 2017年 yanyan. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef VAR_0(ID_0, ID_1) {
VAR_1 = 0,
VAR_2 = 1 << 0,
VAR_3 = 1 << 1,
VAR_4 = 1 << 2,
VAR_5 = 1 << 3,
};
@VAR_6 FUNC_0(VAR_7)
- (CLASS_0 *)VAR_8:(VAR_9 *)VAR_10 VAR_11:(VAR_12)VAR_11 borderType:(ID_1)VAR_13;
//在 view 里面
- (CLASS_0 *)VAR_14:(VAR_9 *)VAR_10 borderWidth:(ID_2)VAR_11 borderType:(ID_1)VAR_13;
@VAR_15
| 0.955814 | {'VAR_0': 'NS_OPTIONS', 'ID_0': 'NSUInteger', 'ID_1': 'UIBorderSideType', 'VAR_1': 'UIBorderSideTypeAll', 'VAR_2': 'UIBorderSideTypeTop', 'VAR_3': 'UIBorderSideTypeBottom', 'VAR_4': 'UIBorderSideTypeLeft', 'VAR_5': 'UIBorderSideTypeRight', 'VAR_6': 'interface', 'FUNC_0': 'UIView', 'CLASS_0': 'UIView', 'VAR_7': 'BorderLine', 'VAR_8': 'borderForColor', 'VAR_9': 'UIColor', 'VAR_10': 'color', 'VAR_11': 'borderWidth', 'VAR_12': 'CGFloat', 'ID_2': 'CGFloat', 'VAR_13': 'borderType', 'VAR_14': 'inBorderForColor', 'VAR_15': 'end'} |
//===- RewriteByReferenceParameters.h -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
//===----------------------------------------------------------------------===//
#ifndef POLLY_REWRITEBYREFERENCEPARAMETERS_H
#define POLLY_REWRITEBYREFERENCEPARAMETERS_H
#include "polly/ScopPass.h"
namespace llvm {
class PassRegistry;
class Pass;
class raw_ostream;
} // namespace llvm
namespace polly {
llvm::Pass *createRewriteByrefParamsWrapperPass();
struct RewriteByrefParamsPass : llvm::PassInfoMixin<RewriteByrefParamsPass> {
RewriteByrefParamsPass() {}
llvm::PreservedAnalyses run(llvm::Function &F,
llvm::FunctionAnalysisManager &FAM);
};
} // namespace polly
namespace llvm {
void initializeRewriteByrefParamsWrapperPassPass(llvm::PassRegistry &);
} // namespace llvm
#endif /* POLLY_REWRITEBYREFERENCEPARAMETERS_H */
| //===- RewriteByReferenceParameters.h -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
//===----------------------------------------------------------------------===//
#ifndef VAR_0
#define VAR_0
#include "IMPORT_0"
CLASS_0 VAR_1 {
CLASS_2 VAR_2;
CLASS_2 VAR_3;
CLASS_2 raw_ostream;
} // namespace llvm
CLASS_0 VAR_4 {
llvm::VAR_3 *FUNC_0();
struct CLASS_3 : VAR_1::VAR_6<VAR_5> {
FUNC_1() {}
llvm::VAR_7 FUNC_2(VAR_1::VAR_8 &VAR_9,
VAR_1::VAR_10 &VAR_11);
};
} // namespace polly
CLASS_0 VAR_1 {
void FUNC_3(CLASS_1::VAR_2 &);
} // namespace llvm
#endif /* POLLY_REWRITEBYREFERENCEPARAMETERS_H */
| 0.929666 | {'VAR_0': 'POLLY_REWRITEBYREFERENCEPARAMETERS_H', 'IMPORT_0': 'polly/ScopPass.h', 'CLASS_0': 'namespace', 'VAR_1': 'llvm', 'CLASS_1': 'llvm', 'CLASS_2': 'class', 'VAR_2': 'PassRegistry', 'VAR_3': 'Pass', 'VAR_4': 'polly', 'FUNC_0': 'createRewriteByrefParamsWrapperPass', 'CLASS_3': 'RewriteByrefParamsPass', 'VAR_5': 'RewriteByrefParamsPass', 'FUNC_1': 'RewriteByrefParamsPass', 'VAR_6': 'PassInfoMixin', 'VAR_7': 'PreservedAnalyses', 'FUNC_2': 'run', 'VAR_8': 'Function', 'VAR_9': 'F', 'VAR_10': 'FunctionAnalysisManager', 'VAR_11': 'FAM', 'FUNC_3': 'initializeRewriteByrefParamsWrapperPassPass'} |
//Copyright (c) 2014, IDEO
#include "LemmaList.h"
#include <stdlib.h>
#include <string.h>
#include "jansson.h"
LemmaList* LemmaList_Dejsonify(json_t* json)
{
int listLength;
int i;
LemmaList * list = 0;
list = LemmaList_Create();
listLength = json_array_size(json);
for(i = 0; i < listLength; i++)
{
json_t * subElement = json_array_get(json, i);
if ( json_is_array(subElement) )
{
LemmaList_AddList(list, LemmaList_Dejsonify(subElement));
}
else
{
LemmaList_AddString(list, json_string_value(subElement));
}
}
return list;
}
LemmaList* LemmaList_Deserialize(char const* serializedList)
{
json_error_t error;
json_t* json;
if(serializedList == 0 || strlen(serializedList) == 0)
return 0;
json = json_loads(serializedList, JSON_DISABLE_EOF_CHECK, &error);
if( json == 0 )
return 0;
return LemmaList_Dejsonify(json);
}
| //Copyright (c) 2014, IDEO
#include "IMPORT_0"
#include <IMPORT_1>
#include <IMPORT_2>
#include "jansson.h"
LemmaList* FUNC_0(CLASS_0* VAR_0)
{
int VAR_1;
int VAR_2;
LemmaList * VAR_3 = 0;
VAR_3 = FUNC_1();
VAR_1 = FUNC_2(VAR_0);
for(VAR_2 = 0; VAR_2 < VAR_1; VAR_2++)
{
CLASS_0 * VAR_4 = FUNC_3(VAR_0, VAR_2);
if ( FUNC_4(VAR_4) )
{
FUNC_5(VAR_3, FUNC_0(VAR_4));
}
else
{
FUNC_6(VAR_3, FUNC_7(VAR_4));
}
}
return VAR_3;
}
LemmaList* FUNC_8(char const* VAR_5)
{
CLASS_1 VAR_6;
CLASS_0* VAR_0;
if(VAR_5 == 0 || FUNC_9(VAR_5) == 0)
return 0;
VAR_0 = json_loads(VAR_5, JSON_DISABLE_EOF_CHECK, &VAR_6);
if( VAR_0 == 0 )
return 0;
return FUNC_0(VAR_0);
}
| 0.887817 | {'IMPORT_0': 'LemmaList.h', 'IMPORT_1': 'stdlib.h', 'IMPORT_2': 'string.h', 'FUNC_0': 'LemmaList_Dejsonify', 'CLASS_0': 'json_t', 'VAR_0': 'json', 'VAR_1': 'listLength', 'VAR_2': 'i', 'VAR_3': 'list', 'FUNC_1': 'LemmaList_Create', 'FUNC_2': 'json_array_size', 'VAR_4': 'subElement', 'FUNC_3': 'json_array_get', 'FUNC_4': 'json_is_array', 'FUNC_5': 'LemmaList_AddList', 'FUNC_6': 'LemmaList_AddString', 'FUNC_7': 'json_string_value', 'FUNC_8': 'LemmaList_Deserialize', 'VAR_5': 'serializedList', 'CLASS_1': 'json_error_t', 'VAR_6': 'error', 'FUNC_9': 'strlen'} |
#include <std.h>
inherit ROOM;
object *begging;
void init() {
::init();
add_action("confess", "confess");
add_action("pray", "pray");
}
void create() {
::create();
set_listen_string("default", "You hear the faint sounds of "
"chanting from up the stairs.");
set_listen_string("upstairs", "You hear the chanting of monks.");
set_listen_string("chants", "We serve an old man in a dry season"
"\nA lighthouse keeper in the desert sun\n"
"Dreamers of sleepers and white treason\n"
"We dream of rain and the history of the gun\n");
begging = ({});
set("short", "Praxis monastary");
set("long",
"You are in the ornate monastary of Praxis.\n"
"In this huge open monastary run by Praxis monks, the wretched "
"murders come to confess, and the dead come to pray for resurrection. "
"A small stairway to the east leads to the monastary attic and "
"basement. The Praxis Chapel where monks marry people is north. "
"Boc La Road is outside the monastary to the south. ");
set_exits(
(["south" : "/d/standard/e_boc_la1",
"east" : "/d/standard/stairs",
"north" : "/d/standard/chapel"]) );
set_property("light", 2);
set_property("indoors", 1);
set_items(
(["monastery" : "The home of the Nightmare monks.",
"chamber" : "People come here to pray for resurrection "
"when they die.",
"stairway" : "A small spiral set of stairs leading to "
"the attic and cellar.",
"road" : "Boc La Road."]) );
set_property("no attack", 1);
set_property("no steal", 1);
set_property("no castle", 1);
}
int pray() {
if(!this_player()->query_ghost()) {
notify_fail("The living do not need to pray for revival.\n");
return 0;
}
this_player()->revive();
this_player()->set_hp(10);
this_player()->set_heart_beat(1);
this_player()->set_heal_rate(2);
return 1;
}
int confess(string str) {
object *inv;
int i, ok;
string res;
if(str != "murder") {
notify_fail("Confess what?\n");
return 0;
}
ok = 0;
if(sscanf((string)this_player()->getenv("TITLE"), "%s murderer $N%*s", res)
!= 1) {
notify_fail("You are no murderer.\n");
return 0;
}
i = sizeof(inv = all_inventory(this_object()));
while(i--) if((string)inv[i]->query_class() == "monk") ok = 1;
if(!ok) {
write("There is no one here to whom you may confess.");
return 1;
}
message("my_action", "You beg the monks for forgiveness for "
"your murder of a "+lower_case(res)+".", this_player());
message("my_action", ("You pray that forgiveness does not mean "
"death."), this_player());
say(this_player()->query_cap_name()+" begs for "+
this_player()->query_possessive()+" murder of a "+
lower_case(str)+".");
begging += ({ this_player() });
call_out("forgive", 60, this_player());
return 1;
}
object *query_forgiven() { return begging; }
void forgive(object ob) {
string tmp;
if(member_array(ob, begging) == -1) return;
begging -= ({ ob });
tmp = (string)call_other("/d/standard/"+(string)ob->query_class()+"_hall",
"get_new_title", ob);
message("info", "You are now forgiven.", ob);
ob->setenv("TITLE", tmp);
ob->add_mp(-500);
ob->add_hp(100- ((int)ob->query_skill("faith")));
}
| #include <std.h>
inherit VAR_0;
CLASS_0 *begging;
void init() {
::init();
add_action("confess", "confess");
add_action("pray", "pray");
}
void FUNC_0() {
::FUNC_0();
set_listen_string("default", "You hear the faint sounds of "
"chanting from up the stairs.");
set_listen_string("upstairs", "You hear the chanting of monks.");
set_listen_string("chants", "We serve an old man in a dry season"
"\nA lighthouse keeper in the desert sun\n"
"Dreamers of sleepers and white treason\n"
"We dream of rain and the history of the gun\n");
begging = ({});
set("short", "Praxis monastary");
set("long",
"You are in the ornate monastary of Praxis.\n"
"In this huge open monastary run by Praxis monks, the wretched "
"murders come to confess, and the dead come to pray for resurrection. "
"A small stairway to the east leads to the monastary attic and "
"basement. The Praxis Chapel where monks marry people is north. "
"Boc La Road is outside the monastary to the south. ");
set_exits(
(VAR_2["south" : "/VAR_3/VAR_4/e_boc_la1",
"VAR_5" : "/VAR_3/VAR_4/stairs",
"north" : "/VAR_3/VAR_4/chapel"]) );
set_property("light", 2);
set_property("indoors", 1);
FUNC_1(
(["monastery" : "The home of the Nightmare monks.",
"chamber" : "People come here to pray for resurrection "
"when they die.",
"stairway" : "A small spiral set of stairs leading to "
"the attic and cellar.",
"road" : "Boc La Road."]) );
set_property("no attack", 1);
set_property("no steal", 1);
set_property("no castle", 1);
}
int pray() {
if(!FUNC_2()->FUNC_3()) {
notify_fail("The living do not need to pray for revival.\n");
return 0;
}
FUNC_2()->FUNC_4();
VAR_6()->FUNC_5(10);
VAR_6()->set_heart_beat(1);
VAR_6()->set_heal_rate(2);
return 1;
}
int confess(string VAR_7) {
VAR_1 *inv;
int VAR_8, ok;
string VAR_9;
if(VAR_7 != "murder") {
notify_fail("Confess what?\n");
return 0;
}
ok = 0;
if(sscanf((string)FUNC_2()->getenv("TITLE"), "%s murderer $N%*s", VAR_9)
!= 1) {
notify_fail("You are no murderer.\n");
return 0;
}
VAR_8 = sizeof(inv = all_inventory(FUNC_6()));
while(VAR_8--) if((string)inv[VAR_8]->query_class() == "monk") ok = 1;
if(!ok) {
write("There is no one here to whom you may confess.");
return 1;
}
FUNC_7("my_action", "You beg the monks for forgiveness for "
"your murder of a "+lower_case(VAR_9)+".", FUNC_2());
VAR_10("my_action", ("You pray that forgiveness does not mean "
"death."), FUNC_2());
say(VAR_6()->FUNC_8()+" begs for "+
FUNC_2()->FUNC_9()+" murder of a "+
lower_case(VAR_7)+".");
begging += ({ CLASS_1() });
FUNC_10("forgive", 60, FUNC_2());
return 1;
}
VAR_1 *query_forgiven() { return begging; }
void FUNC_11(CLASS_0 VAR_11) {
string VAR_12;
if(member_array(VAR_11, begging) == -1) return;
begging -= ({ VAR_11 });
VAR_12 = (string)FUNC_12("/d/standard/"+(string)VAR_11->query_class()+"_hall",
"get_new_title", VAR_11);
FUNC_7("info", "You are now forgiven.", VAR_11);
VAR_11->setenv("TITLE", VAR_12);
VAR_11->FUNC_13(-500);
VAR_11->add_hp(100- ((int)VAR_11->FUNC_14("faith")));
}
| 0.51474 | {'VAR_0': 'ROOM', 'CLASS_0': 'object', 'VAR_1': 'object', 'FUNC_0': 'create', 'VAR_2': '', 'VAR_3': 'd', 'VAR_4': 'standard', 'VAR_5': 'east', 'FUNC_1': 'set_items', 'FUNC_2': 'this_player', 'VAR_6': 'this_player', 'CLASS_1': 'this_player', 'FUNC_3': 'query_ghost', 'FUNC_4': 'revive', 'FUNC_5': 'set_hp', 'VAR_7': 'str', 'VAR_8': 'i', 'VAR_9': 'res', 'FUNC_6': 'this_object', 'FUNC_7': 'message', 'VAR_10': 'message', 'FUNC_8': 'query_cap_name', 'FUNC_9': 'query_possessive', 'FUNC_10': 'call_out', 'FUNC_11': 'forgive', 'VAR_11': 'ob', 'VAR_12': 'tmp', 'FUNC_12': 'call_other', 'FUNC_13': 'add_mp', 'FUNC_14': 'query_skill'} |
/* back-bone - provides access to the internal database */
#include <stdio.h>
#include "back.h"
int back_bone(UNUSED int argc, UNUSED char** argv) {
BACK_ERR("subcommand 'bone' not yet implemented");
return -1;
}
| /* back-bone - provides access to the internal database */
#include <IMPORT_0>
#include "IMPORT_1"
int back_bone(UNUSED int argc, UNUSED char** argv) {
BACK_ERR("subcommand 'bone' not yet implemented");
return -1;
}
| 0.174827 | {'IMPORT_0': 'stdio.h', 'IMPORT_1': 'back.h'} |
#pragma once
#include "BF/System/Log.h"
#include "BF/Platform/API/OpenGL/GLCommon.h"
#include "BF/Common.h"
namespace BF
{
namespace Platform
{
namespace API
{
namespace OpenGL
{
const char* GetGLError(GLenum error);
#ifdef _DEBUG
#define GLCall(stmt) \
do { stmt; \
GLenum error = glGetError(); \
if (error != GL_NO_ERROR) \
BF_LOG_ERROR("OpenGL %s - %s", GetGLError(error), #stmt); \
} while (false)
#else
#define GLCall(stmt) stmt
#endif
}
}
}
} | #pragma once
#include "IMPORT_0"
#include "BF/Platform/API/OpenGL/GLCommon.h"
#include "IMPORT_1"
CLASS_0 VAR_0
{
CLASS_0 Platform
{
CLASS_0 VAR_1
{
CLASS_0 OpenGL
{
const char* FUNC_0(GLenum VAR_2);
#ifdef VAR_3
#define FUNC_1(VAR_4) \
do { stmt; \
GLenum error = glGetError(); \
if (error != GL_NO_ERROR) \
BF_LOG_ERROR("OpenGL %s - %s", GetGLError(error), #stmt); \
} while (false)
#else
#define FUNC_1(VAR_4) stmt
#endif
}
}
}
} | 0.772703 | {'IMPORT_0': 'BF/System/Log.h', 'IMPORT_1': 'BF/Common.h', 'CLASS_0': 'namespace', 'VAR_0': 'BF', 'VAR_1': 'API', 'FUNC_0': 'GetGLError', 'VAR_2': 'error', 'VAR_3': '_DEBUG', 'FUNC_1': 'GLCall', 'VAR_4': 'stmt'} |
#ifndef ALBUMMODEL_H
#define ALBUMMODEL_H
#include <QAbstractTableModel>
#include <QDebug>
#include "muse_client.h"
class AlbumModel : public QAbstractTableModel
{
Q_OBJECT
public:
AlbumModel(QObject *parent = 0);
void populateData(struct albuminfolst* albums);
void addData(struct albuminfolst* albums);
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
void clearModel();
private:
QList<qint64> ids;
QList<QString> titles;
QList<QString> years;
};
#endif // ALBUMMODEL_H
| #ifndef VAR_0
#define VAR_0
#include <IMPORT_0>
#include <QDebug>
#include "IMPORT_1"
class VAR_1 : VAR_2 IMPORT_0
{
Q_OBJECT
VAR_2:
FUNC_0(QObject *parent = 0);
void populateData(struct CLASS_0* VAR_3);
void addData(struct CLASS_0* VAR_3);
int rowCount(const QModelIndex &parent = QModelIndex()) const CLASS_1;
int VAR_5(const QModelIndex &parent = QModelIndex()) const CLASS_1;
CLASS_2 FUNC_1(const QModelIndex &VAR_6, int role = Qt::DisplayRole) const VAR_4;
CLASS_2 FUNC_2(int section, Qt::VAR_7 VAR_8, int role = Qt::DisplayRole) const VAR_4;
void clearModel();
private:
QList<VAR_9> VAR_10;
QList<VAR_11> titles;
QList<VAR_11> VAR_12;
};
#endif // ALBUMMODEL_H
| 0.419745 | {'VAR_0': 'ALBUMMODEL_H', 'IMPORT_0': 'QAbstractTableModel', 'IMPORT_1': 'muse_client.h', 'VAR_1': 'AlbumModel', 'FUNC_0': 'AlbumModel', 'VAR_2': 'public', 'CLASS_0': 'albuminfolst', 'VAR_3': 'albums', 'CLASS_1': 'Q_DECL_OVERRIDE', 'VAR_4': 'Q_DECL_OVERRIDE', 'VAR_5': 'columnCount', 'CLASS_2': 'QVariant', 'FUNC_1': 'data', 'VAR_6': 'index', 'FUNC_2': 'headerData', 'VAR_7': 'Orientation', 'VAR_8': 'orientation', 'VAR_9': 'qint64', 'VAR_10': 'ids', 'VAR_11': 'QString', 'VAR_12': 'years'} |
// My code
#include <lcm/lcm-cpp.hpp>
struct worldmap
{
double map[1000][1000];
};
struct rotMat_t
{
double R[3][3];
};
struct xyzq_pose_t{
double xyz[3];
double wxyz_quaternion[4];
};
int WORLD_SIZE = 10;
float LOCAL_MAP_SIZE = 1.5; // in meters
int CELLS_PER_M = ceil((float) 100 / LOCAL_MAP_SIZE);
xyzq_pose_t lidar_pose;
state_estimator_lcmt state_estimator_pose;
lcm::LCM vision_lcm("udpm://192.168.127.12:7667?ttl=255");
xyzq_pose_t poseFromRPY(double x, double y, double z, double roll, double pitch, double yaw) // yaw (Z), pitch (Y), roll (X)
{
// Abbreviations for the various angular functions
double cy = cos(yaw * 0.5);
double sy = sin(yaw * 0.5);
double cp = cos(pitch * 0.5);
double sp = sin(pitch * 0.5);
double cr = cos(roll * 0.5);
double sr = sin(roll * 0.5);
xyzq_pose_t pose;
pose.xyz[0] = x;
pose.xyz[1] = y;
pose.xyz[2] = z;
pose.wxyz_quaternion[0] = cy * cp * cr + sy * sp * sr;
pose.wxyz_quaternion[1] = cy * cp * sr - sy * sp * cr;
pose.wxyz_quaternion[2] = sy * cp * sr + cy * sp * cr;
pose.wxyz_quaternion[3] = sy * cp * cr - cy * sp * sr;
return pose;
}
rotMat_t poseToRotationMatrix(xyzq_pose_t pose){
double e0 = pose.wxyz_quaternion[0]; // w x y z
double e1 = pose.wxyz_quaternion[1];
double e2 = pose.wxyz_quaternion[2];
double e3 = pose.wxyz_quaternion[3];
rotMat_t rotMat;
rotMat.R[0][0] = 1-2*(e2*e2 + e3*e3);
rotMat.R[1][0] = 2*(e1*e2 - e0*e3);
rotMat.R[2][0] = 2*(e1*e3 + e0*e2);
rotMat.R[0][1] = 2*(e1*e2 + e0*e3);
rotMat.R[1][1] = 1-2*(e1*e1 + e3*e3);
rotMat.R[2][1] = 2*(e2*e3 - e0*e1);
rotMat.R[0][2] = 2*(e1*e3 - e0*e2);
rotMat.R[1][2] = 2*(e2*e3 + e0*e1);
rotMat.R[2][2] = 1-2*(e1*e1 + e2*e2);
return rotMat;
}
xyzq_pose_t stateEstimatorToXYZQPose(state_estimator_lcmt state_estimate){
xyzq_pose_t xyzq_pose;
xyzq_pose.xyz[0] = (double) state_estimate.p[0];
xyzq_pose.xyz[1] = (double) state_estimate.p[1];
xyzq_pose.xyz[2] = (double) state_estimate.p[2];
//xyzq_pose.xyz[0] = 0.;
//xyzq_pose.xyz[1] = 0.;
//xyzq_pose.xyz[2] = 0.;
xyzq_pose.wxyz_quaternion[0] = (double) state_estimate.quat[0];
xyzq_pose.wxyz_quaternion[1] = (double) state_estimate.quat[1];
xyzq_pose.wxyz_quaternion[2] = (double) state_estimate.quat[2];
xyzq_pose.wxyz_quaternion[3] = (double) state_estimate.quat[3];
return xyzq_pose;
}
xyzq_pose_t rsPoseToXYZQPose(const rs2::pose_frame & pose_frame){
xyzq_pose_t xyzq_pose;
auto pose_data = pose_frame.get_pose_data();
xyzq_pose.xyz[0] = (double) pose_data.translation.x;
xyzq_pose.xyz[1] = (double) pose_data.translation.y;
xyzq_pose.xyz[2] = (double) pose_data.translation.z;
xyzq_pose.wxyz_quaternion[0] = (double) pose_data.rotation.w;
xyzq_pose.wxyz_quaternion[1] = (double) pose_data.rotation.x;
xyzq_pose.wxyz_quaternion[2] = (double) pose_data.rotation.y;
xyzq_pose.wxyz_quaternion[3] = (double) pose_data.rotation.z;
return xyzq_pose;
}
void coordinateTransformation( const xyzq_pose_t & pose,
const rs_pointcloud_t & inputCloud,
rs_pointcloud_t & outputCloud)
{
rotMat_t rotationMatrix = poseToRotationMatrix(pose);
/*
printf("mat: %f, %f, %f \n %f, %f, %f, \n, %f, %f,%f\n",
rotationMatrix.R[0][0], rotationMatrix.R[0][1], rotationMatrix.R[0][2],
rotationMatrix.R[1][0], rotationMatrix.R[1][1], rotationMatrix.R[1][2],
rotationMatrix.R[2][0], rotationMatrix.R[2][1], rotationMatrix.R[2][2]);
*/
int r1 = 3, c1=3, num_pts = 5000;
for (int pt_idx(0); pt_idx<num_pts; ++pt_idx){
for (int i=0; i<r1; i++){
outputCloud.pointlist[pt_idx][i] = pose.xyz[i];
for(int k=0; k<c1; k++){
outputCloud.pointlist[pt_idx][i] +=
rotationMatrix.R[k][i]*inputCloud.pointlist[pt_idx][k];
}
}
}
}
void extractLocalFromWorldHeightmap(xyzq_pose_t* lidar_pose_ptr, worldmap* worldmap_ptr, heightmap_t* local_heightmap_ptr)
{
//Copy out local heightmap
// calculate index of center of local map in world map
int pose_x_ind = (*lidar_pose_ptr).xyz[0]*CELLS_PER_M + WORLD_SIZE*CELLS_PER_M/2 -1;
int pose_y_ind = (*lidar_pose_ptr).xyz[1]*CELLS_PER_M + WORLD_SIZE*CELLS_PER_M/2 -1;
int UPPER_LIM = floor(((double)CELLS_PER_M) * LOCAL_MAP_SIZE);
for (int i = 0; i < UPPER_LIM; i++)
{
for (int j = 0; j < UPPER_LIM; j++)
{
int world_map_x_ind = pose_x_ind+i-UPPER_LIM/2;
int world_map_y_ind = pose_y_ind+j-UPPER_LIM/2;
if (world_map_x_ind >= 0 && world_map_x_ind < WORLD_SIZE*CELLS_PER_M &&
world_map_y_ind >= 0 && world_map_y_ind < WORLD_SIZE*CELLS_PER_M)
{
(*local_heightmap_ptr).map[i][j] = (*worldmap_ptr).map[world_map_x_ind][world_map_y_ind];
}
}
}
}
void wfPCtoHeightmap(rs_pointcloud_t* wf_pointcloud_ptr, worldmap* world_heightmap_ptr, int num_valid_points){
// Move world frame point cloud into world heightmap
for (int i = 0; i < num_valid_points; i++)
{
int point_x_ind = (*wf_pointcloud_ptr).pointlist[i][0]*CELLS_PER_M + WORLD_SIZE*CELLS_PER_M/2 -1;
int point_y_ind = (*wf_pointcloud_ptr).pointlist[i][1]*CELLS_PER_M + WORLD_SIZE*CELLS_PER_M/2 -1;
if (point_x_ind >= 0 && point_x_ind < WORLD_SIZE*CELLS_PER_M && point_y_ind >= 0 && point_y_ind < WORLD_SIZE*CELLS_PER_M)
{
(*world_heightmap_ptr).map[point_x_ind][point_y_ind] = (*wf_pointcloud_ptr).pointlist[i][2];
}
}
}
class LidarPoseHandler
{
public:
~LidarPoseHandler() {}
void handlePose(const lcm::ReceiveBuffer* rbuf,
const std::string& chan,
const xyzq_pose_t* msg)
{
lidar_pose = *msg;
//std::cout<<"receive lidar"<<std::endl;
}
};
class StateEstimatorPoseHandler
{
public:
~StateEstimatorPoseHandler() {}
void handlePose(const lcm::ReceiveBuffer* rbuf,
const std::string& chan,
const state_estimator_lcmt* msg)
{
state_estimator_pose = *msg;
//std::cout<<"receive lidar"<<std::endl;
}
};
void handleLCM() {
while (true) {
vision_lcm.handle();
};
}
| // My code
#include <lcm/lcm-cpp.hpp>
struct CLASS_0
{
double map[1000][1000];
};
struct CLASS_1
{
double R[3][3];
};
struct CLASS_2{
double VAR_0[3];
double VAR_1[4];
};
int WORLD_SIZE = 10;
float VAR_2 = 1.5; // in meters
int VAR_3 = FUNC_0((float) 100 / VAR_2);
CLASS_2 VAR_4;
CLASS_3 state_estimator_pose;
lcm::VAR_5 FUNC_1("udpm://192.168.127.12:7667?ttl=255");
CLASS_2 FUNC_2(double VAR_7, double VAR_8, double VAR_9, double roll, double pitch, double VAR_10) // yaw (Z), pitch (Y), roll (X)
{
// Abbreviations for the various angular functions
double VAR_11 = FUNC_3(VAR_10 * 0.5);
double VAR_12 = sin(VAR_10 * 0.5);
double cp = FUNC_3(pitch * 0.5);
double VAR_13 = sin(pitch * 0.5);
double cr = FUNC_3(roll * 0.5);
double VAR_14 = sin(roll * 0.5);
CLASS_2 pose;
pose.VAR_0[0] = VAR_7;
pose.VAR_0[1] = VAR_8;
pose.VAR_0[2] = VAR_9;
pose.VAR_1[0] = VAR_11 * cp * cr + VAR_12 * VAR_13 * VAR_14;
pose.VAR_1[1] = VAR_11 * cp * VAR_14 - VAR_12 * VAR_13 * cr;
pose.VAR_1[2] = VAR_12 * cp * VAR_14 + VAR_11 * VAR_13 * cr;
pose.VAR_1[3] = VAR_12 * cp * cr - VAR_11 * VAR_13 * VAR_14;
return pose;
}
CLASS_1 poseToRotationMatrix(CLASS_2 pose){
double e0 = pose.VAR_1[0]; // w x y z
double e1 = pose.VAR_1[1];
double e2 = pose.VAR_1[2];
double e3 = pose.VAR_1[3];
CLASS_1 VAR_15;
VAR_15.R[0][0] = 1-2*(e2*e2 + e3*e3);
VAR_15.R[1][0] = 2*(e1*e2 - e0*e3);
VAR_15.R[2][0] = 2*(e1*e3 + e0*e2);
VAR_15.R[0][1] = 2*(e1*e2 + e0*e3);
VAR_15.R[1][1] = 1-2*(e1*e1 + e3*e3);
VAR_15.R[2][1] = 2*(e2*e3 - e0*e1);
VAR_15.R[0][2] = 2*(e1*e3 - e0*e2);
VAR_15.R[1][2] = 2*(e2*e3 + e0*e1);
VAR_15.R[2][2] = 1-2*(e1*e1 + e2*e2);
return VAR_15;
}
CLASS_2 FUNC_4(CLASS_3 VAR_16){
CLASS_2 VAR_17;
VAR_17.VAR_0[0] = (double) VAR_16.VAR_18[0];
VAR_17.VAR_0[1] = (double) VAR_16.VAR_18[1];
VAR_17.VAR_0[2] = (double) VAR_16.VAR_18[2];
//xyzq_pose.xyz[0] = 0.;
//xyzq_pose.xyz[1] = 0.;
//xyzq_pose.xyz[2] = 0.;
VAR_17.VAR_1[0] = (double) VAR_16.VAR_19[0];
VAR_17.VAR_1[1] = (double) VAR_16.VAR_19[1];
VAR_17.VAR_1[2] = (double) VAR_16.VAR_19[2];
VAR_17.VAR_1[3] = (double) VAR_16.VAR_19[3];
return VAR_17;
}
CLASS_2 FUNC_5(const CLASS_5::VAR_20 & VAR_20){
CLASS_2 VAR_17;
auto pose_dataVAR_21 = VAR_20.FUNC_6();
VAR_17.VAR_0[0] = (double) pose_data.VAR_22.VAR_7;
VAR_17.VAR_0[1] = (double) pose_data.VAR_22.VAR_8;
VAR_17.VAR_0[2] = (double) pose_data.VAR_22.VAR_9;
VAR_17.VAR_1[0] = (double) pose_data.VAR_23.w;
VAR_17.VAR_1[1] = (double) pose_data.VAR_23.VAR_7;
VAR_17.VAR_1[2] = (double) pose_data.VAR_23.VAR_8;
VAR_17.VAR_1[3] = (double) pose_data.VAR_23.VAR_9;
return VAR_17;
}
void coordinateTransformation( const CLASS_2 & pose,
const rs_pointcloud_t & VAR_24,
rs_pointcloud_t & outputCloud)
{
CLASS_1 VAR_25 = poseToRotationMatrix(pose);
/*
printf("mat: %f, %f, %f \n %f, %f, %f, \n, %f, %f,%f\n",
rotationMatrix.R[0][0], rotationMatrix.R[0][1], rotationMatrix.R[0][2],
rotationMatrix.R[1][0], rotationMatrix.R[1][1], rotationMatrix.R[1][2],
rotationMatrix.R[2][0], rotationMatrix.R[2][1], rotationMatrix.R[2][2]);
*/
int VAR_26 = 3, VAR_27=3, VAR_28 = 5000;
for (int FUNC_7(0); VAR_29<VAR_28; ++VAR_29){
for (int VAR_30=0; VAR_30<VAR_26; VAR_30++){
outputCloud.VAR_31[VAR_29][VAR_30] = pose.VAR_0[VAR_30];
for(int k=0; k<VAR_27; k++){
outputCloud.VAR_31[VAR_29][VAR_30] +=
VAR_25.R[k][VAR_30]*VAR_24.VAR_31[VAR_29][k];
}
}
}
}
void FUNC_8(CLASS_2* VAR_32, CLASS_0* worldmap_ptr, CLASS_6* VAR_33)
{
//Copy out local heightmap
// calculate index of center of local map in world map
int VAR_34 = (*VAR_32).VAR_0[0]*VAR_3 + WORLD_SIZE*VAR_3/2 -1;
int VAR_35 = (*VAR_32).VAR_0[1]*VAR_3 + WORLD_SIZE*VAR_3/2 -1;
int VAR_36 = floor(((double)VAR_3) * VAR_2);
for (int VAR_30 = 0; VAR_30 < VAR_36; VAR_30++)
{
for (int VAR_37 = 0; VAR_37 < VAR_36; VAR_37++)
{
int VAR_38 = VAR_34+VAR_30-VAR_36/2;
int VAR_39 = VAR_35+VAR_37-VAR_36/2;
if (VAR_38 >= 0 && VAR_38 < WORLD_SIZE*VAR_3 &&
VAR_39 >= 0 && VAR_39 < WORLD_SIZE*VAR_3)
{
(*VAR_33).map[VAR_30][VAR_37] = (*worldmap_ptr).map[VAR_38][VAR_39];
}
}
}
}
void FUNC_9(rs_pointcloud_t* VAR_40, CLASS_0* VAR_41, int num_valid_points){
// Move world frame point cloud into world heightmap
for (int VAR_30 = 0; VAR_30 < num_valid_points; VAR_30++)
{
int VAR_42 = (*VAR_40).VAR_31[VAR_30][0]*VAR_3 + WORLD_SIZE*VAR_3/2 -1;
int VAR_43 = (*VAR_40).VAR_31[VAR_30][1]*VAR_3 + WORLD_SIZE*VAR_3/2 -1;
if (VAR_42 >= 0 && VAR_42 < WORLD_SIZE*VAR_3 && VAR_43 >= 0 && VAR_43 < WORLD_SIZE*VAR_3)
{
(*VAR_41).map[VAR_42][VAR_43] = (*VAR_40).VAR_31[VAR_30][2];
}
}
}
CLASS_7 VAR_44
{
public:
~FUNC_10() {}
void handlePose(const CLASS_4::VAR_45* rbuf,
const CLASS_8::string& chan,
const CLASS_2* VAR_46)
{
VAR_4 = *VAR_46;
//std::cout<<"receive lidar"<<std::endl;
}
};
CLASS_7 VAR_47
{
public:
~FUNC_11() {}
void handlePose(const CLASS_4::VAR_45* rbuf,
const CLASS_8::string& chan,
const CLASS_3* VAR_46)
{
state_estimator_pose = *VAR_46;
//std::cout<<"receive lidar"<<std::endl;
}
};
void FUNC_12() {
while (true) {
VAR_6.FUNC_13();
};
}
| 0.735961 | {'CLASS_0': 'worldmap', 'CLASS_1': 'rotMat_t', 'CLASS_2': 'xyzq_pose_t', 'VAR_0': 'xyz', 'VAR_1': 'wxyz_quaternion', 'VAR_2': 'LOCAL_MAP_SIZE', 'VAR_3': 'CELLS_PER_M', 'FUNC_0': 'ceil', 'VAR_4': 'lidar_pose', 'CLASS_3': 'state_estimator_lcmt', 'CLASS_4': 'lcm', 'VAR_5': 'LCM', 'FUNC_1': 'vision_lcm', 'VAR_6': 'vision_lcm', 'FUNC_2': 'poseFromRPY', 'VAR_7': 'x', 'VAR_8': 'y', 'VAR_9': 'z', 'VAR_10': 'yaw', 'VAR_11': 'cy', 'FUNC_3': 'cos', 'VAR_12': 'sy', 'VAR_13': 'sp', 'VAR_14': 'sr', 'VAR_15': 'rotMat', 'FUNC_4': 'stateEstimatorToXYZQPose', 'VAR_16': 'state_estimate', 'VAR_17': 'xyzq_pose', 'VAR_18': 'p', 'VAR_19': 'quat', 'FUNC_5': 'rsPoseToXYZQPose', 'CLASS_5': 'rs2', 'VAR_20': 'pose_frame', 'VAR_21': '', 'FUNC_6': 'get_pose_data', 'VAR_22': 'translation', 'VAR_23': 'rotation', 'VAR_24': 'inputCloud', 'VAR_25': 'rotationMatrix', 'VAR_26': 'r1', 'VAR_27': 'c1', 'VAR_28': 'num_pts', 'FUNC_7': 'pt_idx', 'VAR_29': 'pt_idx', 'VAR_30': 'i', 'VAR_31': 'pointlist', 'FUNC_8': 'extractLocalFromWorldHeightmap', 'VAR_32': 'lidar_pose_ptr', 'CLASS_6': 'heightmap_t', 'VAR_33': 'local_heightmap_ptr', 'VAR_34': 'pose_x_ind', 'VAR_35': 'pose_y_ind', 'VAR_36': 'UPPER_LIM', 'VAR_37': 'j', 'VAR_38': 'world_map_x_ind', 'VAR_39': 'world_map_y_ind', 'FUNC_9': 'wfPCtoHeightmap', 'VAR_40': 'wf_pointcloud_ptr', 'VAR_41': 'world_heightmap_ptr', 'VAR_42': 'point_x_ind', 'VAR_43': 'point_y_ind', 'CLASS_7': 'class', 'VAR_44': 'LidarPoseHandler', 'FUNC_10': 'LidarPoseHandler', 'VAR_45': 'ReceiveBuffer', 'CLASS_8': 'std', 'VAR_46': 'msg', 'VAR_47': 'StateEstimatorPoseHandler', 'FUNC_11': 'StateEstimatorPoseHandler', 'FUNC_12': 'handleLCM', 'FUNC_13': 'handle'} |
/*****************************************************************************
Major portions of this software are copyrighted by the Medical College
of Wisconsin, 1994-2000, and are released under the Gnu General Public
License, Version 2. See the file README.Copyright for details.
******************************************************************************/
#include "mrilib.h"
#include "thd.h"
/*-----------------------------------------------------------------------
Create FD_bricks for viewing purposes.
FD_bricks are a relic of the very earliest code that evolved into
AFNI. By the time I invented THD_3dim_datasets, I had enough code
in place to keep this data structure alive. Basically, it exists
only to provide a structure that enables fast copying of data out
of a 3D array into 2D arrays.
-------------------------------------------------------------------------*/
FD_brick ** THD_setup_bricks( THD_3dim_dataset * dset )
{
int r2l=0 , a2p=0 , i2s=0 ;
THD_dataxes *daxes ;
FD_brick **br ;
ENTRY("THD_setup_bricks") ;
if( ! ISVALID_3DIM_DATASET(dset) ) RETURN(NULL) ;
daxes = CURRENT_DAXES(dset) ;
if( ! ISVALID_DATAXES(daxes) ) RETURN(NULL) ;
/*----- create FD_bricks for viewing purposes -----*/
switch( daxes->xxorient ){
case ORI_R2L_TYPE: r2l = 1 ; break ;
case ORI_L2R_TYPE: r2l = -1 ; break ;
case ORI_P2A_TYPE: a2p = -1 ; break ;
case ORI_A2P_TYPE: a2p = 1 ; break ;
case ORI_I2S_TYPE: i2s = 1 ; break ;
case ORI_S2I_TYPE: i2s = -1 ; break ;
}
switch( daxes->yyorient ){
case ORI_R2L_TYPE: r2l = 2 ; break ;
case ORI_L2R_TYPE: r2l = -2 ; break ;
case ORI_P2A_TYPE: a2p = -2 ; break ;
case ORI_A2P_TYPE: a2p = 2 ; break ;
case ORI_I2S_TYPE: i2s = 2 ; break ;
case ORI_S2I_TYPE: i2s = -2 ; break ;
}
switch( daxes->zzorient ){
case ORI_R2L_TYPE: r2l = 3 ; break ;
case ORI_L2R_TYPE: r2l = -3 ; break ;
case ORI_P2A_TYPE: a2p = -3 ; break ;
case ORI_A2P_TYPE: a2p = 3 ; break ;
case ORI_I2S_TYPE: i2s = 3 ; break ;
case ORI_S2I_TYPE: i2s = -3 ; break ;
}
if( r2l==0 || a2p==0 || i2s==0 ){
char buf[256] ;
sprintf(buf,"Illegal orientation codes: %d %d %d",
daxes->xxorient,daxes->yyorient,daxes->zzorient ) ;
THD_FATAL_ERROR(buf) ;
}
/* now we can set up views: axial, sagittal, coronal;
the top option is the way I think it ought to be, so that
in the axial and coronal views, left is left and right is right;
the bottom options are the radiologists conventions, so sue me! */
br = (FD_brick **) RwcMalloc( sizeof(FD_brick *) * 3 ) ;
#undef LEFT_IS_LEFT
#ifdef LEFT_IS_LEFT
br[0] = THD_3dim_dataset_to_brick(dset,-r2l, a2p,-i2s); /* axi */
br[1] = THD_3dim_dataset_to_brick(dset, a2p,-i2s,-r2l); /* sag */
br[2] = THD_3dim_dataset_to_brick(dset,-r2l,-i2s,-a2p); /* cor */
#else
br[0] = THD_3dim_dataset_to_brick(dset, r2l, a2p, i2s); /* axi */
br[1] = THD_3dim_dataset_to_brick(dset, a2p,-i2s,-r2l); /* sag */
br[2] = THD_3dim_dataset_to_brick(dset, r2l,-i2s, a2p); /* cor */
#endif
MCW_strncpy( br[0]->namecode , "Axial" , 32 ) ;
MCW_strncpy( br[1]->namecode , "Sagittal" , 32 ) ;
MCW_strncpy( br[2]->namecode , "Coronal" , 32 ) ;
RETURN(br) ;
}
/*----------------------------------------------------------------------
07 Dec 2001 - orient an FD brick in any legal way
(e.g., orients = "RAI" for standard axial)
------------------------------------------------------------------------*/
FD_brick * THD_oriented_brick( THD_3dim_dataset *dset , char *orients )
{
int r2l=0 , a2p=0 , i2s=0 , xx,yy,zz , pp=0,qq=0,rr=0 ;
THD_dataxes *daxes ;
FD_brick *br ;
ENTRY("THD_oriented_brick") ;
if( !ISVALID_DSET(dset) ||
orients == NULL ||
strlen(orients) < 3 ) RETURN(NULL) ;
daxes = CURRENT_DAXES(dset) ;
if( !ISVALID_DATAXES(daxes) ) RETURN(NULL) ;
xx = ORCODE( orients[0] ) ;
yy = ORCODE( orients[1] ) ;
zz = ORCODE( orients[2] ) ;
if( !OR3OK(xx,yy,zz) ) RETURN(NULL) ;
/*----- create FD_bricks for viewing purposes -----*/
switch( daxes->xxorient ){
case ORI_R2L_TYPE: r2l = 1 ; break ;
case ORI_L2R_TYPE: r2l = -1 ; break ;
case ORI_P2A_TYPE: a2p = -1 ; break ;
case ORI_A2P_TYPE: a2p = 1 ; break ;
case ORI_I2S_TYPE: i2s = 1 ; break ;
case ORI_S2I_TYPE: i2s = -1 ; break ;
}
switch( daxes->yyorient ){
case ORI_R2L_TYPE: r2l = 2 ; break ;
case ORI_L2R_TYPE: r2l = -2 ; break ;
case ORI_P2A_TYPE: a2p = -2 ; break ;
case ORI_A2P_TYPE: a2p = 2 ; break ;
case ORI_I2S_TYPE: i2s = 2 ; break ;
case ORI_S2I_TYPE: i2s = -2 ; break ;
}
switch( daxes->zzorient ){
case ORI_R2L_TYPE: r2l = 3 ; break ;
case ORI_L2R_TYPE: r2l = -3 ; break ;
case ORI_P2A_TYPE: a2p = -3 ; break ;
case ORI_A2P_TYPE: a2p = 3 ; break ;
case ORI_I2S_TYPE: i2s = 3 ; break ;
case ORI_S2I_TYPE: i2s = -3 ; break ;
}
if( r2l==0 || a2p==0 || i2s==0 ) RETURN(NULL) ;
switch( xx ){
case ORI_R2L_TYPE: pp = r2l ; break ;
case ORI_L2R_TYPE: pp = -r2l ; break ;
case ORI_P2A_TYPE: pp = -a2p ; break ;
case ORI_A2P_TYPE: pp = a2p ; break ;
case ORI_I2S_TYPE: pp = i2s ; break ;
case ORI_S2I_TYPE: pp = -i2s ; break ;
}
switch( yy ){
case ORI_R2L_TYPE: qq = r2l ; break ;
case ORI_L2R_TYPE: qq = -r2l ; break ;
case ORI_P2A_TYPE: qq = -a2p ; break ;
case ORI_A2P_TYPE: qq = a2p ; break ;
case ORI_I2S_TYPE: qq = i2s ; break ;
case ORI_S2I_TYPE: qq = -i2s ; break ;
}
switch( zz ){
case ORI_R2L_TYPE: rr = r2l ; break ;
case ORI_L2R_TYPE: rr = -r2l ; break ;
case ORI_P2A_TYPE: rr = -a2p ; break ;
case ORI_A2P_TYPE: rr = a2p ; break ;
case ORI_I2S_TYPE: rr = i2s ; break ;
case ORI_S2I_TYPE: rr = -i2s ; break ;
}
if( pp==0 || qq==0 || rr==0 ) RETURN(NULL) ;
br = THD_3dim_dataset_to_brick(dset,pp,qq,rr) ;
RETURN(br) ;
}
/*======================================================================
routines adapted from original afni code for display of a 3D dataset
========================================================================*/
/*----------------------------------------------------------------------
prepare a "display brick" for a 3D dataset;
ax_n = 1,2,3 for displaying the x,y,z axis along the n-th display
direction (n=1 --> across, n=2 --> down, n=3 --> slices )
negative value means reverse
a return of NULL means something bad happened
------------------------------------------------------------------------*/
FD_brick * THD_3dim_dataset_to_brick( THD_3dim_dataset *dset ,
int ax_1, int ax_2, int ax_3 )
{
FD_brick *br ; /* will be output */
THD_dataxes *daxes ; /* connection to actual axes */
int xyz_dim[4] , xyz_stp[4] , xyz_dir[4] ;
float xyz_del[4] , xyz_org[4] ;
int x_dir,y_dir,z_dir , sx,sy,sz , aax_1,aax_2,aax_3 , nx,ny,nz ;
/*-- sanity check --*/
ENTRY("THD_3dim_dataset_to_brick") ;
if( ! ISVALID_3DIM_DATASET(dset) ) RETURN(NULL) ;
daxes = CURRENT_DAXES(dset) ;
aax_1 = abs(ax_1) ; /* which axes, regardless of + or - */
aax_2 = abs(ax_2) ;
aax_3 = abs(ax_3) ;
if( aax_1 < 1 || aax_1 > 3 || /* range checks */
aax_2 < 1 || aax_2 > 3 ||
aax_3 < 1 || aax_3 > 3 ) RETURN(NULL) ;
xyz_dir[1] = xyz_dir[2] = xyz_dir[3] = 0 ;
xyz_dir[aax_1] = ax_1 ; /* assign to original directions */
xyz_dir[aax_2] = ax_2 ;
xyz_dir[aax_3] = ax_3 ;
x_dir = xyz_dir[1] ; /* if any |ax_n| is duplicated */
y_dir = xyz_dir[2] ; /* then one of these will end */
z_dir = xyz_dir[3] ; /* up as zero --> bad inputs! */
if( x_dir == 0 || y_dir == 0 || z_dir == 0 ) RETURN(NULL) ;
/*-- the inputs are good, so create a brick: --*/
br = myRwcNew(FD_brick) ; /* new brick */
br->dset = dset ; /* dataset */
br->resam_code = RESAM_NN_TYPE ; /* crudest type */
br->parent = NULL ;
br->brother = NULL ;
br->deltival = 0 ; /* 23 Feb 2011 */
br->thr_resam_code = RESAM_NN_TYPE ; /* 09 Dec 1997 */
/*-- at this point, x_dir is +1 or -1, y_dir is +2 or -2, etc. --*/
nx = daxes->nxx ; ny = daxes->nyy ; nz = daxes->nzz ;
sx = (x_dir > 0) ? (0) : (nx-1) ; /* starting voxel indices */
sy = (y_dir > 0) ? (0) : (ny-1) ; /* for each original dimension */
sz = (z_dir > 0) ? (0) : (nz-1) ;
br->start = sx + sy*nx + sz*nx*ny ; /* overall starting voxel index */
/*-- assign original dimensions to arrays,
then pick out the permuted dimensions --*/
xyz_dim[1] = nx ; /* dimensions */
xyz_dim[2] = ny ;
xyz_dim[3] = nz ;
LOAD_IVEC3( br->nxyz , nx,ny,nz ) ; /* save stuff in br */
LOAD_IVEC3( br->sxyz , sx,sy,sz ) ;
LOAD_IVEC3( br->a123 , ax_1,ax_2,ax_3 ) ;
xyz_stp[1] = 1 ; /* index step sizes */
xyz_stp[2] = nx ;
xyz_stp[3] = nx * ny ;
xyz_del[1] = daxes->xxdel ; /* voxel physical step sizes (mm) */
xyz_del[2] = daxes->yydel ;
xyz_del[3] = daxes->zzdel ;
xyz_org[1] = daxes->xxorg ; /* voxel origins (mm) */
xyz_org[2] = daxes->yyorg ;
xyz_org[3] = daxes->zzorg ;
br->n1 = xyz_dim[aax_1] ; /* permute dimensions, etc. */
br->n2 = xyz_dim[aax_2] ;
br->n3 = xyz_dim[aax_3] ;
br->d1 = (ax_1 > 0) ? (xyz_stp[aax_1]) : (-xyz_stp[aax_1]) ;
br->d2 = (ax_2 > 0) ? (xyz_stp[aax_2]) : (-xyz_stp[aax_2]) ;
br->d3 = (ax_3 > 0) ? (xyz_stp[aax_3]) : (-xyz_stp[aax_3]) ;
br->e1 = br->n1 * br->d1 ; /* last indices for readout */
br->e2 = br->n2 * br->d2 ;
br->del1 = fabs(xyz_del[aax_1]) ; /* dimensions */
br->del2 = fabs(xyz_del[aax_2]) ;
br->del3 = fabs(xyz_del[aax_3]) ;
br->namecode[0] = '\0' ;
br->tmask = NULL ;
br->ntmask = -666 ;
RETURN(br) ;
}
| /*****************************************************************************
Major portions of this software are copyrighted by the Medical College
of Wisconsin, 1994-2000, and are released under the Gnu General Public
License, Version 2. See the file README.Copyright for details.
******************************************************************************/
#include "mrilib.h"
#include "thd.h"
/*-----------------------------------------------------------------------
Create FD_bricks for viewing purposes.
FD_bricks are a relic of the very earliest code that evolved into
AFNI. By the time I invented THD_3dim_datasets, I had enough code
in place to keep this data structure alive. Basically, it exists
only to provide a structure that enables fast copying of data out
of a 3D array into 2D arrays.
-------------------------------------------------------------------------*/
FD_brick ** THD_setup_bricks( THD_3dim_dataset * dset )
{
int r2l=0 , VAR_0=0 , VAR_1=0 ;
CLASS_0 *VAR_2 ;
FD_brick **br ;
ENTRY("THD_setup_bricks") ;
if( ! FUNC_0(dset) ) RETURN(NULL) ;
VAR_2 = CURRENT_DAXES(dset) ;
if( ! ISVALID_DATAXES(VAR_2) ) RETURN(NULL) ;
/*----- create FD_bricks for viewing purposes -----*/
switch( VAR_2->VAR_3 ){
case ORI_R2L_TYPE: r2l = 1 ; break ;
case ORI_L2R_TYPE: r2l = -1 ; break ;
case VAR_4: VAR_0 = -1 ; break ;
case ORI_A2P_TYPE: VAR_0 = 1 ; break ;
case ORI_I2S_TYPE: VAR_1 = 1 ; break ;
case VAR_5: VAR_1 = -1 ; break ;
}
switch( VAR_2->yyorient ){
case ORI_R2L_TYPE: r2l = 2 ; break ;
case ORI_L2R_TYPE: r2l = -2 ; break ;
case VAR_4: VAR_0 = -2 ; break ;
case ORI_A2P_TYPE: VAR_0 = 2 ; break ;
case ORI_I2S_TYPE: VAR_1 = 2 ; break ;
case VAR_5: VAR_1 = -2 ; break ;
}
switch( VAR_2->zzorient ){
case ORI_R2L_TYPE: r2l = 3 ; break ;
case ORI_L2R_TYPE: r2l = -3 ; break ;
case VAR_4: VAR_0 = -3 ; break ;
case ORI_A2P_TYPE: VAR_0 = 3 ; break ;
case ORI_I2S_TYPE: VAR_1 = 3 ; break ;
case VAR_5: VAR_1 = -3 ; break ;
}
if( r2l==0 || VAR_0==0 || VAR_1==0 ){
char buf[256] ;
sprintf(buf,"Illegal orientation codes: %d %d %d",
VAR_2->VAR_3,VAR_2->yyorient,VAR_2->zzorient ) ;
THD_FATAL_ERROR(buf) ;
}
/* now we can set up views: axial, sagittal, coronal;
the top option is the way I think it ought to be, so that
in the axial and coronal views, left is left and right is right;
the bottom options are the radiologists conventions, so sue me! */
br = (FD_brick **) RwcMalloc( sizeof(FD_brick *) * 3 ) ;
#undef LEFT_IS_LEFT
#ifdef LEFT_IS_LEFT
br[0] = THD_3dim_dataset_to_brick(dset,-r2l, VAR_0,-VAR_1); /* axi */
br[1] = THD_3dim_dataset_to_brick(dset, VAR_0,-VAR_1,-r2l); /* sag */
br[2] = THD_3dim_dataset_to_brick(dset,-r2l,-VAR_1,-VAR_0); /* cor */
#else
br[0] = THD_3dim_dataset_to_brick(dset, r2l, VAR_0, VAR_1); /* axi */
br[1] = THD_3dim_dataset_to_brick(dset, VAR_0,-VAR_1,-r2l); /* sag */
br[2] = THD_3dim_dataset_to_brick(dset, r2l,-VAR_1, VAR_0); /* cor */
#endif
MCW_strncpy( br[0]->namecode , "Axial" , 32 ) ;
MCW_strncpy( br[1]->namecode , "Sagittal" , 32 ) ;
MCW_strncpy( br[2]->namecode , "Coronal" , 32 ) ;
RETURN(br) ;
}
/*----------------------------------------------------------------------
07 Dec 2001 - orient an FD brick in any legal way
(e.g., orients = "RAI" for standard axial)
------------------------------------------------------------------------*/
FD_brick * THD_oriented_brick( THD_3dim_dataset *dset , char *VAR_6 )
{
int r2l=0 , VAR_0=0 , VAR_1=0 , VAR_7,VAR_8,zz , VAR_9=0,VAR_10=0,rr=0 ;
CLASS_0 *VAR_2 ;
FD_brick *br ;
ENTRY("THD_oriented_brick") ;
if( !ISVALID_DSET(dset) ||
VAR_6 == NULL ||
strlen(VAR_6) < 3 ) RETURN(NULL) ;
VAR_2 = CURRENT_DAXES(dset) ;
if( !ISVALID_DATAXES(VAR_2) ) RETURN(NULL) ;
VAR_7 = ORCODE( VAR_6[0] ) ;
VAR_8 = ORCODE( VAR_6[1] ) ;
zz = ORCODE( VAR_6[2] ) ;
if( !FUNC_1(VAR_7,VAR_8,zz) ) RETURN(NULL) ;
/*----- create FD_bricks for viewing purposes -----*/
switch( VAR_2->VAR_3 ){
case ORI_R2L_TYPE: r2l = 1 ; break ;
case ORI_L2R_TYPE: r2l = -1 ; break ;
case VAR_4: VAR_0 = -1 ; break ;
case ORI_A2P_TYPE: VAR_0 = 1 ; break ;
case ORI_I2S_TYPE: VAR_1 = 1 ; break ;
case VAR_5: VAR_1 = -1 ; break ;
}
switch( VAR_2->yyorient ){
case ORI_R2L_TYPE: r2l = 2 ; break ;
case ORI_L2R_TYPE: r2l = -2 ; break ;
case VAR_4: VAR_0 = -2 ; break ;
case ORI_A2P_TYPE: VAR_0 = 2 ; break ;
case ORI_I2S_TYPE: VAR_1 = 2 ; break ;
case VAR_5: VAR_1 = -2 ; break ;
}
switch( VAR_2->zzorient ){
case ORI_R2L_TYPE: r2l = 3 ; break ;
case ORI_L2R_TYPE: r2l = -3 ; break ;
case VAR_4: VAR_0 = -3 ; break ;
case ORI_A2P_TYPE: VAR_0 = 3 ; break ;
case ORI_I2S_TYPE: VAR_1 = 3 ; break ;
case VAR_5: VAR_1 = -3 ; break ;
}
if( r2l==0 || VAR_0==0 || VAR_1==0 ) RETURN(NULL) ;
switch( VAR_7 ){
case ORI_R2L_TYPE: VAR_9 = r2l ; break ;
case ORI_L2R_TYPE: VAR_9 = -r2l ; break ;
case VAR_4: VAR_9 = -VAR_0 ; break ;
case ORI_A2P_TYPE: VAR_9 = VAR_0 ; break ;
case ORI_I2S_TYPE: VAR_9 = VAR_1 ; break ;
case VAR_5: VAR_9 = -VAR_1 ; break ;
}
switch( VAR_8 ){
case ORI_R2L_TYPE: VAR_10 = r2l ; break ;
case ORI_L2R_TYPE: VAR_10 = -r2l ; break ;
case VAR_4: VAR_10 = -VAR_0 ; break ;
case ORI_A2P_TYPE: VAR_10 = VAR_0 ; break ;
case ORI_I2S_TYPE: VAR_10 = VAR_1 ; break ;
case VAR_5: VAR_10 = -VAR_1 ; break ;
}
switch( zz ){
case ORI_R2L_TYPE: rr = r2l ; break ;
case ORI_L2R_TYPE: rr = -r2l ; break ;
case VAR_4: rr = -VAR_0 ; break ;
case ORI_A2P_TYPE: rr = VAR_0 ; break ;
case ORI_I2S_TYPE: rr = VAR_1 ; break ;
case VAR_5: rr = -VAR_1 ; break ;
}
if( VAR_9==0 || VAR_10==0 || rr==0 ) RETURN(NULL) ;
br = THD_3dim_dataset_to_brick(dset,VAR_9,VAR_10,rr) ;
RETURN(br) ;
}
/*======================================================================
routines adapted from original afni code for display of a 3D dataset
========================================================================*/
/*----------------------------------------------------------------------
prepare a "display brick" for a 3D dataset;
ax_n = 1,2,3 for displaying the x,y,z axis along the n-th display
direction (n=1 --> across, n=2 --> down, n=3 --> slices )
negative value means reverse
a return of NULL means something bad happened
------------------------------------------------------------------------*/
FD_brick * THD_3dim_dataset_to_brick( THD_3dim_dataset *dset ,
int ax_1, int VAR_11, int ax_3 )
{
FD_brick *br ; /* will be output */
CLASS_0 *VAR_2 ; /* connection to actual axes */
int xyz_dim[4] , xyz_stp[4] , xyz_dir[4] ;
float xyz_del[4] , VAR_12[4] ;
int VAR_13,y_dir,z_dir , VAR_14,VAR_15,sz , aax_1,aax_2,aax_3 , VAR_16,VAR_17,nz ;
/*-- sanity check --*/
ENTRY("THD_3dim_dataset_to_brick") ;
if( ! FUNC_0(dset) ) RETURN(NULL) ;
VAR_2 = CURRENT_DAXES(dset) ;
aax_1 = FUNC_2(ax_1) ; /* which axes, regardless of + or - */
aax_2 = FUNC_2(VAR_11) ;
aax_3 = FUNC_2(ax_3) ;
if( aax_1 < 1 || aax_1 > 3 || /* range checks */
aax_2 < 1 || aax_2 > 3 ||
aax_3 < 1 || aax_3 > 3 ) RETURN(NULL) ;
xyz_dir[1] = xyz_dir[2] = xyz_dir[3] = 0 ;
xyz_dir[aax_1] = ax_1 ; /* assign to original directions */
xyz_dir[aax_2] = VAR_11 ;
xyz_dir[aax_3] = ax_3 ;
VAR_13 = xyz_dir[1] ; /* if any |ax_n| is duplicated */
y_dir = xyz_dir[2] ; /* then one of these will end */
z_dir = xyz_dir[3] ; /* up as zero --> bad inputs! */
if( VAR_13 == 0 || y_dir == 0 || z_dir == 0 ) RETURN(NULL) ;
/*-- the inputs are good, so create a brick: --*/
br = myRwcNew(FD_brick) ; /* new brick */
br->dset = dset ; /* dataset */
br->resam_code = RESAM_NN_TYPE ; /* crudest type */
br->VAR_18 = NULL ;
br->brother = NULL ;
br->deltival = 0 ; /* 23 Feb 2011 */
br->thr_resam_code = RESAM_NN_TYPE ; /* 09 Dec 1997 */
/*-- at this point, x_dir is +1 or -1, y_dir is +2 or -2, etc. --*/
VAR_16 = VAR_2->nxx ; VAR_17 = VAR_2->nyy ; nz = VAR_2->nzz ;
VAR_14 = (VAR_13 > 0) ? (0) : (VAR_16-1) ; /* starting voxel indices */
VAR_15 = (y_dir > 0) ? (0) : (VAR_17-1) ; /* for each original dimension */
sz = (z_dir > 0) ? (0) : (nz-1) ;
br->start = VAR_14 + VAR_15*VAR_16 + sz*VAR_16*VAR_17 ; /* overall starting voxel index */
/*-- assign original dimensions to arrays,
then pick out the permuted dimensions --*/
xyz_dim[1] = VAR_16 ; /* dimensions */
xyz_dim[2] = VAR_17 ;
xyz_dim[3] = nz ;
FUNC_3( br->nxyz , VAR_16,VAR_17,nz ) ; /* save stuff in br */
FUNC_3( br->sxyz , VAR_14,VAR_15,sz ) ;
FUNC_3( br->a123 , ax_1,VAR_11,ax_3 ) ;
xyz_stp[1] = 1 ; /* index step sizes */
xyz_stp[2] = VAR_16 ;
xyz_stp[3] = VAR_16 * VAR_17 ;
xyz_del[1] = VAR_2->xxdel ; /* voxel physical step sizes (mm) */
xyz_del[2] = VAR_2->yydel ;
xyz_del[3] = VAR_2->zzdel ;
VAR_12[1] = VAR_2->xxorg ; /* voxel origins (mm) */
VAR_12[2] = VAR_2->yyorg ;
VAR_12[3] = VAR_2->zzorg ;
br->n1 = xyz_dim[aax_1] ; /* permute dimensions, etc. */
br->n2 = xyz_dim[aax_2] ;
br->n3 = xyz_dim[aax_3] ;
br->d1 = (ax_1 > 0) ? (xyz_stp[aax_1]) : (-xyz_stp[aax_1]) ;
br->VAR_19 = (VAR_11 > 0) ? (xyz_stp[aax_2]) : (-xyz_stp[aax_2]) ;
br->d3 = (ax_3 > 0) ? (xyz_stp[aax_3]) : (-xyz_stp[aax_3]) ;
br->VAR_20 = br->n1 * br->d1 ; /* last indices for readout */
br->e2 = br->n2 * br->VAR_19 ;
br->VAR_21 = fabs(xyz_del[aax_1]) ; /* dimensions */
br->del2 = fabs(xyz_del[aax_2]) ;
br->VAR_22 = fabs(xyz_del[aax_3]) ;
br->namecode[0] = '\0' ;
br->tmask = NULL ;
br->VAR_23 = -666 ;
RETURN(br) ;
}
| 0.283545 | {'VAR_0': 'a2p', 'VAR_1': 'i2s', 'CLASS_0': 'THD_dataxes', 'VAR_2': 'daxes', 'FUNC_0': 'ISVALID_3DIM_DATASET', 'VAR_3': 'xxorient', 'VAR_4': 'ORI_P2A_TYPE', 'VAR_5': 'ORI_S2I_TYPE', 'VAR_6': 'orients', 'VAR_7': 'xx', 'VAR_8': 'yy', 'VAR_9': 'pp', 'VAR_10': 'qq', 'FUNC_1': 'OR3OK', 'VAR_11': 'ax_2', 'VAR_12': 'xyz_org', 'VAR_13': 'x_dir', 'VAR_14': 'sx', 'VAR_15': 'sy', 'VAR_16': 'nx', 'VAR_17': 'ny', 'FUNC_2': 'abs', 'VAR_18': 'parent', 'FUNC_3': 'LOAD_IVEC3', 'VAR_19': 'd2', 'VAR_20': 'e1', 'VAR_21': 'del1', 'VAR_22': 'del3', 'VAR_23': 'ntmask'} |
/*Writes the bit pattern for the run length of a super block run to the given
oggpack_buffer.
_opb: The buffer to write to.
_run_count: The length of the run, which must be positive.
_flag: The current flag.
_done: Whether or not more flags are to be encoded.*/
static void oc_sb_run_pack(oggpack_buffer *_opb,ptrdiff_t _run_count,
int _flag,int _done){
int i;
if(_run_count>=4129){
do{
oggpackB_write(_opb,0x3FFFF,18);
_run_count-=4129;
if(_run_count>0)oggpackB_write(_opb,_flag,1);
else if(!_done)oggpackB_write(_opb,!_flag,1);
}
while(_run_count>=4129);
if(_run_count<=0)return;
}
for(i=0;_run_count>=OC_SB_RUN_VAL_MIN[i+1];i++);
oggpackB_write(_opb,OC_SB_RUN_CODE_PREFIX[i]+_run_count-OC_SB_RUN_VAL_MIN[i],
OC_SB_RUN_CODE_NBITS[i]);
} | /*Writes the bit pattern for the run length of a super block run to the given
oggpack_buffer.
_opb: The buffer to write to.
_run_count: The length of the run, which must be positive.
_flag: The current flag.
_done: Whether or not more flags are to be encoded.*/
static void FUNC_0(CLASS_0 *VAR_0,ptrdiff_t VAR_1,
int VAR_2,int VAR_3){
int VAR_4;
if(VAR_1>=4129){
do{
FUNC_1(VAR_0,0x3FFFF,18);
VAR_1-=4129;
if(VAR_1>0)FUNC_1(VAR_0,VAR_2,1);
else if(!VAR_3)FUNC_1(VAR_0,!VAR_2,1);
}
while(VAR_1>=4129);
if(VAR_1<=0)return;
}
for(VAR_4=0;VAR_1>=VAR_5[VAR_4+1];VAR_4++);
FUNC_1(VAR_0,VAR_6[VAR_4]+VAR_1-VAR_5[VAR_4],
VAR_7[VAR_4]);
} | 0.91446 | {'FUNC_0': 'oc_sb_run_pack', 'CLASS_0': 'oggpack_buffer', 'VAR_0': '_opb', 'VAR_1': '_run_count', 'VAR_2': '_flag', 'VAR_3': '_done', 'VAR_4': 'i', 'FUNC_1': 'oggpackB_write', 'VAR_5': 'OC_SB_RUN_VAL_MIN', 'VAR_6': 'OC_SB_RUN_CODE_PREFIX', 'VAR_7': 'OC_SB_RUN_CODE_NBITS'} |
/**
* ZeroDark.cloud Framework
*
* Homepage : https://www.zerodark.cloud
* GitHub : https://github.com/4th-ATechnologies/ZeroDark.cloud
* Documentation : https://zerodarkcloud.readthedocs.io/en/latest/
* API Reference : https://apis.zerodark.cloud
**/
#import <UIKit/UIKit.h>
typedef NS_OPTIONS(NSUInteger, ZDCPopoverTransitionOrigin) {
ZDCPopoverTransitionOrigin_Top = 1 << 0,
ZDCPopoverTransitionOrigin_Bottom = 1 << 1,
ZDCPopoverTransitionOrigin_Left = 1 << 2,
ZDCPopoverTransitionOrigin_Right = 1 << 3,
};
@interface ZDCPopoverTransition : NSObject <UIViewControllerAnimatedTransitioning>
@property (nonatomic, assign, readwrite) BOOL reverse;
@property (nonatomic, assign, readwrite) NSTimeInterval duration;
@property (nonatomic, assign, readwrite) ZDCPopoverTransitionOrigin origin;
@end
| /**
* ZeroDark.cloud Framework
*
* Homepage : https://www.zerodark.cloud
* GitHub : https://github.com/4th-ATechnologies/ZeroDark.cloud
* Documentation : https://zerodarkcloud.readthedocs.io/en/latest/
* API Reference : https://apis.zerodark.cloud
**/
#import <UIKit/UIKit.h>
typedef NS_OPTIONS(NSUInteger, ZDCPopoverTransitionOrigin) {
ZDCPopoverTransitionOrigin_Top = 1 << 0,
ZDCPopoverTransitionOrigin_Bottom = 1 << 1,
ZDCPopoverTransitionOrigin_Left = 1 << 2,
ZDCPopoverTransitionOrigin_Right = 1 << 3,
};
@interface ZDCPopoverTransition : NSObject <UIViewControllerAnimatedTransitioning>
@FUNC_0 (nonatomic, assign, readwrite) BOOL reverse;
@FUNC_0 (nonatomic, assign, readwrite) NSTimeInterval duration;
@FUNC_0 (nonatomic, assign, readwrite) ZDCPopoverTransitionOrigin VAR_0;
@end
| 0.180138 | {'FUNC_0': 'property', 'VAR_0': 'origin'} |
/******************************************************************************
** COPYRIGHT NOTICE
** (c) 2012 The Johns Hopkins University Applied Physics Laboratory
** All rights reserved.
**
******************************************************************************/
/*****************************************************************************
**
** File Name: adm_adm_bp_impl.c
**
** Description: This implements the private aspects of a BP ADM.
**
** Notes:
**
** Assumptions:
**
** Modification History:
** MM/DD/YY AUTHOR DESCRIPTION
** -------- ------------ ---------------------------------------------
** <NAME> Initial Implementation (JHU/APL)
** 08/21/16 <NAME> Updated to Agent ADM v0.2 (Secure DTN - NASA: NNX14CS58P)
*****************************************************************************/
#include "ion.h"
#include "lyst.h"
#include "platform.h"
#include "../shared/adm/adm_bp.h"
#include "../shared/utils/utils.h"
#include "../shared/primitives/ctrl.h"
#include "adm_bp_impl.h"
value_t adm_bp_md_name(tdc_t params)
{
return val_from_string("BP ADM");
}
value_t adm_bp_md_ver(tdc_t params)
{
return val_from_string("v6");
}
value_t adm_bp_node_get_node_id(tdc_t params)
{
value_t result;
NmbpNode node_state;
bpnm_node_get(&node_state);
result.type = AMP_TYPE_STRING;
result.value.as_ptr = adm_copy_string((char *) node_state.nodeID, NULL);
return result;
}
value_t adm_bp_node_get_version(tdc_t params)
{
value_t result;
NmbpNode node_state;
bpnm_node_get(&node_state);
result.type = AMP_TYPE_STRING;
result.value.as_ptr = adm_copy_string((char *) node_state.bpVersionNbr, NULL);
return result;
}
value_t adm_bp_node_get_storage(tdc_t params)
{
value_t result;
NmbpNode node_state;
bpnm_node_get(&node_state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = node_state.avblStorage;
return result;
}
value_t adm_bp_node_get_last_restart(tdc_t params)
{
value_t result;
NmbpNode node_state;
bpnm_node_get(&node_state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = node_state.lastRestartTime;
return result;
}
value_t adm_bp_node_get_num_reg(tdc_t params)
{
value_t result;
NmbpNode node_state;
bpnm_node_get(&node_state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = node_state.nbrOfRegistrations;
return result;
}
value_t adm_bp_node_get_fwd_pend(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.currentForwardPending;
return result;
}
value_t adm_bp_node_get_dispatch_pend(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.currentDispatchPending;
return result;
}
value_t adm_bp_node_get_in_cust(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.currentInCustody;
return result;
}
value_t adm_bp_node_get_reassembly_pend(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.currentReassemblyPending;
return result;
}
value_t adm_bp_node_get_blk_src_cnt(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundleSourceCount[0];
return result;
}
value_t adm_bp_node_get_norm_src_cnt(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundleSourceCount[1];
return result;
}
value_t adm_bp_node_get_exp_src_cnt(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundleSourceCount[2];
return result;
}
value_t adm_bp_node_get_blk_src_bytes(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundleSourceBytes[0];
return result;
}
value_t adm_bp_node_get_norm_src_bytes(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundleSourceBytes[1];
return result;
}
value_t adm_bp_node_get_exp_src_bytes(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundleSourceBytes[2];
return result;
}
value_t adm_bp_node_get_blk_res_cnt(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.currentResidentCount[0];
return result;
}
value_t adm_bp_node_get_norm_res_cnt(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.currentResidentCount[1];
return result;
}
value_t adm_bp_node_get_exp_res_cnt(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.currentResidentCount[2];
return result;
}
value_t adm_bp_node_get_blk_res_bytes(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.currentResidentBytes[0];
return result;
}
value_t adm_bp_node_get_norm_res_bytes(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.currentResidentBytes[1];
return result;
}
value_t adm_bp_node_get_exp_res_bytes(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.currentResidentBytes[2];
return result;
}
value_t adm_bp_node_get_bundles_frag(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundlesFragmented;
return result;
}
value_t adm_bp_node_get_frag_produced(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.fragmentsProduced;
return result;
}
value_t adm_bp_node_get_del_none(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.delNoneCount;
return result;
}
value_t adm_bp_node_get_del_expired(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.delExpiredCount;
return result;
}
value_t adm_bp_node_get_del_fwd_uni(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.delFwdUnidirCount;
return result;
}
value_t adm_bp_node_get_del_cancel(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.delCanceledCount;
return result;
}
value_t adm_bp_node_get_del_deplete(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.delDepletionCount;
return result;
}
value_t adm_bp_node_get_del_bad_eid(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.delEidMalformedCount;
return result;
}
value_t adm_bp_node_get_del_no_route(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.delNoRouteCount;
return result;
}
value_t adm_bp_node_get_del_no_contact(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.delNoContactCount;
return result;
}
value_t adm_bp_node_get_del_bad_blk(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.delBlkMalformedCount;
return result;
}
value_t adm_bp_node_get_del_bytes(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bytesDeletedToDate;
return result;
}
value_t adm_bp_node_get_fail_cust_cnt(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.custodyRefusedCount;
return result;
}
value_t adm_bp_node_get_fail_cust_bytes(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.custodyRefusedBytes;
return result;
}
value_t adm_bp_node_get_fail_fwd_cnt(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundleFwdFailedCount;
return result;
}
value_t adm_bp_node_get_fail_fwd_bytes(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundleFwdFailedBytes;
return result;
}
value_t adm_bp_node_get_fail_abandon_cnt(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundleAbandonCount;
return result;
}
value_t adm_bp_node_get_fail_abandon_bytes(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundleAbandonBytes;
return result;
}
value_t adm_bp_node_get_fail_discard_cnt(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundleDiscardCount;
return result;
}
value_t adm_bp_node_get_fail_discard_bytes(tdc_t params)
{
value_t result;
NmbpDisposition state;
bpnm_disposition_get(&state);
result.type = AMP_TYPE_UVAST;
result.value.as_uvast = state.bundleDiscardBytes;
return result;
}
value_t adm_bp_endpoint_get_names(tdc_t params)
{
char names[2048];
char *ptrs[128];
int num = 0;
value_t result;
uint32_t size = 0;
uint8_t *cursor = NULL;
uint8_t first = 0;
int i = 0;
val_init(&result);
bpnm_endpointNames_get((char *) names, 2048, ptrs, &num);
for(i = 0; i < num; i++)
{
size += strlen(ptrs[i]) + 2; // string + ", "
}
if((result.value.as_ptr = (uint8_t *) STAKE(size + 1)) == NULL)
{
AMP_DEBUG_ERR("adm_bp_endpoint_get_names","Cannot allocate %d bytes for %d eids.", size, num);
return result;
}
result.type = AMP_TYPE_STRING;
cursor = result.value.as_ptr;
memset(cursor, 0, size + 1);
for(i = 0; i < num; i++)
{
if(first == 0)
{
first = 1;
}
else
{
sprintf((char*)cursor,", ");
cursor += 2;
}
sprintf((char*)cursor, "%s", ptrs[i]);
cursor += strlen(ptrs[i]);
}
return result;
}
value_t adm_bp_endpoint_get_name(tdc_t params)
{
char *name = NULL;
value_t result;
uint32_t size = 0;
NmbpEndpoint endpoint;
int success = 0;
int8_t adm_success = 0;
val_init(&result);
if((name = adm_extract_string(params, 0, &adm_success)) == NULL)
{
AMP_DEBUG_ERR("adm_bp_endpoint_get_name","No endpoint name given.", NULL);
return result;
}
result.value.as_ptr = NULL;
bpnm_endpoint_get(name, &endpoint, &success);
if(success != 0)
{
result.type = AMP_TYPE_STRING;
size = (uint64_t) strlen(endpoint.eid) + 1;
result.value.as_ptr = (uint8_t*) STAKE(size);
if (result.value.as_ptr == NULL)
{
putErrmsg("Can't create result.value.as_ptr.", NULL);
SRELEASE(name);
return result;
}
memset(result.value.as_ptr,0,size);
memcpy(result.value.as_ptr, endpoint.eid, size);
}
SRELEASE(name);
return result;
}
value_t adm_bp_endpoint_get_active(tdc_t params)
{
char *name = NULL;
value_t result;
val_init(&result);
NmbpEndpoint endpoint;
int success = 0;
int8_t adm_success = 0;
if((name = adm_extract_string(params, 0, &adm_success)) == NULL)
{
AMP_DEBUG_ERR("adm_bp_endpoint_get_active","Can't extract first parm.", NULL);
return result;
}
result.value.as_uint = 0;
bpnm_endpoint_get(name, &endpoint, &success);
if(success != 0)
{
result.type = AMP_TYPE_UINT;
result.value.as_uint = endpoint.active;
}
SRELEASE(name);
return result;
}
value_t adm_bp_endpoint_get_singleton(tdc_t params)
{
char *name = NULL;
value_t result;
NmbpEndpoint endpoint;
int success = 0;
int8_t adm_success = 0;
val_init(&result);
if((name = adm_extract_string(params, 0, &adm_success)) == NULL)
{
AMP_DEBUG_ERR("adm_bp_endpoint_get_singleton","Can't extract first parm.", NULL);
return result;
}
result.value.as_uint = 0;
bpnm_endpoint_get(name, &endpoint, &success);
if(success != 0)
{
result.type = AMP_TYPE_UINT;
result.value.as_uint = endpoint.singleton;
}
SRELEASE(name);
return result;
}
value_t adm_bp_endpoint_get_abandon(tdc_t params)
{
char *name = NULL;
value_t result;
NmbpEndpoint endpoint;
int success = 0;
int8_t adm_success = 0;
val_init(&result);
if((name = adm_extract_string(params, 0, &adm_success)) == NULL)
{
AMP_DEBUG_ERR("adm_bp_endpoint_get_abandon","Can't extract first parm.", NULL);
return result;
}
result.value.as_uint = 0;
bpnm_endpoint_get(name, &endpoint, &success);
if(success != 0)
{
result.type = AMP_TYPE_UINT;
result.value.as_uint = endpoint.abandonOnDelivFailure;
}
SRELEASE(name);
return result;
}
/* Controls */
tdc_t *adm_bp_ctrl_reset(eid_t *def_mgr, tdc_t params, int8_t *status)
{
tdc_t result;
bpnm_disposition_reset();
*status = CTRL_SUCCESS;
memset(&result, 0, sizeof(tdc_t));
return NULL;
}
| /******************************************************************************
** COPYRIGHT NOTICE
** (c) 2012 The Johns Hopkins University Applied Physics Laboratory
** All rights reserved.
**
******************************************************************************/
/*****************************************************************************
**
** File Name: adm_adm_bp_impl.c
**
** Description: This implements the private aspects of a BP ADM.
**
** Notes:
**
** Assumptions:
**
** Modification History:
** MM/DD/YY AUTHOR DESCRIPTION
** -------- ------------ ---------------------------------------------
** <NAME> Initial Implementation (JHU/APL)
** 08/21/16 <NAME> Updated to Agent ADM v0.2 (Secure DTN - NASA: NNX14CS58P)
*****************************************************************************/
#include "IMPORT_0"
#include "lyst.h"
#include "platform.h"
#include "IMPORT_1"
#include "../shared/utils/utils.h"
#include "IMPORT_2"
#include "adm_bp_impl.h"
CLASS_0 FUNC_0(tdc_t VAR_0)
{
return FUNC_1("BP ADM");
}
CLASS_0 adm_bp_md_ver(tdc_t VAR_0)
{
return FUNC_1("v6");
}
CLASS_0 FUNC_2(tdc_t VAR_0)
{
CLASS_0 result;
CLASS_1 VAR_1;
FUNC_3(&VAR_1);
result.VAR_2 = VAR_3;
result.value.VAR_4 = FUNC_4((char *) VAR_1.VAR_5, NULL);
return result;
}
CLASS_0 FUNC_5(tdc_t VAR_0)
{
CLASS_0 result;
CLASS_1 VAR_1;
FUNC_3(&VAR_1);
result.VAR_2 = VAR_3;
result.value.VAR_4 = FUNC_4((char *) VAR_1.bpVersionNbr, NULL);
return result;
}
CLASS_0 adm_bp_node_get_storage(tdc_t VAR_0)
{
CLASS_0 result;
CLASS_1 VAR_1;
FUNC_3(&VAR_1);
result.VAR_2 = VAR_6;
result.value.as_uvast = VAR_1.avblStorage;
return result;
}
CLASS_0 FUNC_6(tdc_t VAR_0)
{
CLASS_0 result;
CLASS_1 VAR_1;
FUNC_3(&VAR_1);
result.VAR_2 = VAR_6;
result.value.as_uvast = VAR_1.VAR_7;
return result;
}
CLASS_0 adm_bp_node_get_num_reg(tdc_t VAR_0)
{
CLASS_0 result;
CLASS_1 VAR_1;
FUNC_3(&VAR_1);
result.VAR_2 = VAR_6;
result.value.as_uvast = VAR_1.VAR_8;
return result;
}
CLASS_0 FUNC_7(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.currentForwardPending;
return result;
}
CLASS_0 FUNC_9(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.currentDispatchPending;
return result;
}
CLASS_0 FUNC_10(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.currentInCustody;
return result;
}
CLASS_0 adm_bp_node_get_reassembly_pend(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.currentReassemblyPending;
return result;
}
CLASS_0 FUNC_11(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.bundleSourceCount[0];
return result;
}
CLASS_0 FUNC_12(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.bundleSourceCount[1];
return result;
}
CLASS_0 adm_bp_node_get_exp_src_cnt(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.bundleSourceCount[2];
return result;
}
CLASS_0 adm_bp_node_get_blk_src_bytes(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_9[0];
return result;
}
CLASS_0 FUNC_13(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_9[1];
return result;
}
CLASS_0 FUNC_14(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_9[2];
return result;
}
CLASS_0 adm_bp_node_get_blk_res_cnt(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.currentResidentCount[0];
return result;
}
CLASS_0 adm_bp_node_get_norm_res_cnt(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.currentResidentCount[1];
return result;
}
CLASS_0 FUNC_15(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.currentResidentCount[2];
return result;
}
CLASS_0 FUNC_16(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.currentResidentBytes[0];
return result;
}
CLASS_0 FUNC_17(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.currentResidentBytes[1];
return result;
}
CLASS_0 adm_bp_node_get_exp_res_bytes(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.currentResidentBytes[2];
return result;
}
CLASS_0 adm_bp_node_get_bundles_frag(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_10;
return result;
}
CLASS_0 FUNC_18(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_11;
return result;
}
CLASS_0 FUNC_19(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_12;
return result;
}
CLASS_0 adm_bp_node_get_del_expired(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.delExpiredCount;
return result;
}
CLASS_0 FUNC_20(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.delFwdUnidirCount;
return result;
}
CLASS_0 FUNC_21(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_13;
return result;
}
CLASS_0 adm_bp_node_get_del_deplete(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.delDepletionCount;
return result;
}
CLASS_0 FUNC_22(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_14;
return result;
}
CLASS_0 adm_bp_node_get_del_no_route(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.delNoRouteCount;
return result;
}
CLASS_0 adm_bp_node_get_del_no_contact(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_15;
return result;
}
CLASS_0 FUNC_23(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.delBlkMalformedCount;
return result;
}
CLASS_0 adm_bp_node_get_del_bytes(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_16;
return result;
}
CLASS_0 adm_bp_node_get_fail_cust_cnt(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_17;
return result;
}
CLASS_0 adm_bp_node_get_fail_cust_bytes(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_18;
return result;
}
CLASS_0 adm_bp_node_get_fail_fwd_cnt(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.bundleFwdFailedCount;
return result;
}
CLASS_0 FUNC_24(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.bundleFwdFailedBytes;
return result;
}
CLASS_0 adm_bp_node_get_fail_abandon_cnt(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_19;
return result;
}
CLASS_0 adm_bp_node_get_fail_abandon_bytes(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_20;
return result;
}
CLASS_0 adm_bp_node_get_fail_discard_cnt(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.VAR_21;
return result;
}
CLASS_0 FUNC_25(tdc_t VAR_0)
{
CLASS_0 result;
NmbpDisposition state;
FUNC_8(&state);
result.VAR_2 = VAR_6;
result.value.as_uvast = state.bundleDiscardBytes;
return result;
}
CLASS_0 adm_bp_endpoint_get_names(tdc_t VAR_0)
{
char VAR_22[2048];
char *ptrs[128];
int num = 0;
CLASS_0 result;
uint32_t VAR_23 = 0;
uint8_t *VAR_24 = NULL;
uint8_t VAR_25 = 0;
int VAR_26 = 0;
FUNC_26(&result);
FUNC_27((char *) VAR_22, 2048, ptrs, &num);
for(VAR_26 = 0; VAR_26 < num; VAR_26++)
{
VAR_23 += strlen(ptrs[VAR_26]) + 2; // string + ", "
}
if((result.value.VAR_4 = (uint8_t *) FUNC_28(VAR_23 + 1)) == NULL)
{
FUNC_29("adm_bp_endpoint_get_names","Cannot allocate %d bytes for %d eids.", VAR_23, num);
return result;
}
result.VAR_2 = VAR_3;
VAR_24 = result.value.VAR_4;
FUNC_30(VAR_24, 0, VAR_23 + 1);
for(VAR_26 = 0; VAR_26 < num; VAR_26++)
{
if(VAR_25 == 0)
{
VAR_25 = 1;
}
else
{
FUNC_31((char*)VAR_24,", ");
VAR_24 += 2;
}
FUNC_31((char*)VAR_24, "%s", ptrs[VAR_26]);
VAR_24 += strlen(ptrs[VAR_26]);
}
return result;
}
CLASS_0 FUNC_32(tdc_t VAR_0)
{
char *name = NULL;
CLASS_0 result;
uint32_t VAR_23 = 0;
NmbpEndpoint VAR_27;
int VAR_28 = 0;
int8_t adm_success = 0;
FUNC_26(&result);
if((name = adm_extract_string(VAR_0, 0, &adm_success)) == NULL)
{
FUNC_29("adm_bp_endpoint_get_name","No endpoint name given.", NULL);
return result;
}
result.value.VAR_4 = NULL;
FUNC_33(name, &VAR_27, &VAR_28);
if(VAR_28 != 0)
{
result.VAR_2 = VAR_3;
VAR_23 = (uint64_t) strlen(VAR_27.VAR_29) + 1;
result.value.VAR_4 = (uint8_t*) FUNC_28(VAR_23);
if (result.value.VAR_4 == NULL)
{
FUNC_34("Can't create result.value.as_ptr.", NULL);
FUNC_35(name);
return result;
}
FUNC_30(result.value.VAR_4,0,VAR_23);
FUNC_36(result.value.VAR_4, VAR_27.VAR_29, VAR_23);
}
FUNC_35(name);
return result;
}
CLASS_0 adm_bp_endpoint_get_active(tdc_t VAR_0)
{
char *name = NULL;
CLASS_0 result;
FUNC_26(&result);
NmbpEndpoint VAR_27;
int VAR_28 = 0;
int8_t adm_success = 0;
if((name = adm_extract_string(VAR_0, 0, &adm_success)) == NULL)
{
FUNC_29("adm_bp_endpoint_get_active","Can't extract first parm.", NULL);
return result;
}
result.value.VAR_30 = 0;
FUNC_33(name, &VAR_27, &VAR_28);
if(VAR_28 != 0)
{
result.VAR_2 = AMP_TYPE_UINT;
result.value.VAR_30 = VAR_27.active;
}
FUNC_35(name);
return result;
}
CLASS_0 adm_bp_endpoint_get_singleton(tdc_t VAR_0)
{
char *name = NULL;
CLASS_0 result;
NmbpEndpoint VAR_27;
int VAR_28 = 0;
int8_t adm_success = 0;
FUNC_26(&result);
if((name = adm_extract_string(VAR_0, 0, &adm_success)) == NULL)
{
FUNC_29("adm_bp_endpoint_get_singleton","Can't extract first parm.", NULL);
return result;
}
result.value.VAR_30 = 0;
FUNC_33(name, &VAR_27, &VAR_28);
if(VAR_28 != 0)
{
result.VAR_2 = AMP_TYPE_UINT;
result.value.VAR_30 = VAR_27.singleton;
}
FUNC_35(name);
return result;
}
CLASS_0 adm_bp_endpoint_get_abandon(tdc_t VAR_0)
{
char *name = NULL;
CLASS_0 result;
NmbpEndpoint VAR_27;
int VAR_28 = 0;
int8_t adm_success = 0;
FUNC_26(&result);
if((name = adm_extract_string(VAR_0, 0, &adm_success)) == NULL)
{
FUNC_29("adm_bp_endpoint_get_abandon","Can't extract first parm.", NULL);
return result;
}
result.value.VAR_30 = 0;
FUNC_33(name, &VAR_27, &VAR_28);
if(VAR_28 != 0)
{
result.VAR_2 = AMP_TYPE_UINT;
result.value.VAR_30 = VAR_27.VAR_31;
}
FUNC_35(name);
return result;
}
/* Controls */
tdc_t *adm_bp_ctrl_reset(eid_t *VAR_32, tdc_t VAR_0, int8_t *status)
{
tdc_t result;
bpnm_disposition_reset();
*status = VAR_33;
FUNC_30(&result, 0, sizeof(tdc_t));
return NULL;
}
| 0.520585 | {'IMPORT_0': 'ion.h', 'IMPORT_1': '../shared/adm/adm_bp.h', 'IMPORT_2': '../shared/primitives/ctrl.h', 'CLASS_0': 'value_t', 'FUNC_0': 'adm_bp_md_name', 'VAR_0': 'params', 'FUNC_1': 'val_from_string', 'FUNC_2': 'adm_bp_node_get_node_id', 'CLASS_1': 'NmbpNode', 'VAR_1': 'node_state', 'FUNC_3': 'bpnm_node_get', 'VAR_2': 'type', 'VAR_3': 'AMP_TYPE_STRING', 'VAR_4': 'as_ptr', 'FUNC_4': 'adm_copy_string', 'VAR_5': 'nodeID', 'FUNC_5': 'adm_bp_node_get_version', 'VAR_6': 'AMP_TYPE_UVAST', 'FUNC_6': 'adm_bp_node_get_last_restart', 'VAR_7': 'lastRestartTime', 'VAR_8': 'nbrOfRegistrations', 'FUNC_7': 'adm_bp_node_get_fwd_pend', 'FUNC_8': 'bpnm_disposition_get', 'FUNC_9': 'adm_bp_node_get_dispatch_pend', 'FUNC_10': 'adm_bp_node_get_in_cust', 'FUNC_11': 'adm_bp_node_get_blk_src_cnt', 'FUNC_12': 'adm_bp_node_get_norm_src_cnt', 'VAR_9': 'bundleSourceBytes', 'FUNC_13': 'adm_bp_node_get_norm_src_bytes', 'FUNC_14': 'adm_bp_node_get_exp_src_bytes', 'FUNC_15': 'adm_bp_node_get_exp_res_cnt', 'FUNC_16': 'adm_bp_node_get_blk_res_bytes', 'FUNC_17': 'adm_bp_node_get_norm_res_bytes', 'VAR_10': 'bundlesFragmented', 'FUNC_18': 'adm_bp_node_get_frag_produced', 'VAR_11': 'fragmentsProduced', 'FUNC_19': 'adm_bp_node_get_del_none', 'VAR_12': 'delNoneCount', 'FUNC_20': 'adm_bp_node_get_del_fwd_uni', 'FUNC_21': 'adm_bp_node_get_del_cancel', 'VAR_13': 'delCanceledCount', 'FUNC_22': 'adm_bp_node_get_del_bad_eid', 'VAR_14': 'delEidMalformedCount', 'VAR_15': 'delNoContactCount', 'FUNC_23': 'adm_bp_node_get_del_bad_blk', 'VAR_16': 'bytesDeletedToDate', 'VAR_17': 'custodyRefusedCount', 'VAR_18': 'custodyRefusedBytes', 'FUNC_24': 'adm_bp_node_get_fail_fwd_bytes', 'VAR_19': 'bundleAbandonCount', 'VAR_20': 'bundleAbandonBytes', 'VAR_21': 'bundleDiscardCount', 'FUNC_25': 'adm_bp_node_get_fail_discard_bytes', 'VAR_22': 'names', 'VAR_23': 'size', 'VAR_24': 'cursor', 'VAR_25': 'first', 'VAR_26': 'i', 'FUNC_26': 'val_init', 'FUNC_27': 'bpnm_endpointNames_get', 'FUNC_28': 'STAKE', 'FUNC_29': 'AMP_DEBUG_ERR', 'FUNC_30': 'memset', 'FUNC_31': 'sprintf', 'FUNC_32': 'adm_bp_endpoint_get_name', 'VAR_27': 'endpoint', 'VAR_28': 'success', 'FUNC_33': 'bpnm_endpoint_get', 'VAR_29': 'eid', 'FUNC_34': 'putErrmsg', 'FUNC_35': 'SRELEASE', 'FUNC_36': 'memcpy', 'VAR_30': 'as_uint', 'VAR_31': 'abandonOnDelivFailure', 'VAR_32': 'def_mgr', 'VAR_33': 'CTRL_SUCCESS'} |
/* zunik.f -- translated by f2c (version 20190311).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
#include "f2c.h"
/* Table of constant values */
static integer c__1 = 1;
/* Subroutine */ int zunik_(doublereal *zrr, doublereal *zri, doublereal *fnu,
integer *ikflg, integer *ipmtr, doublereal *tol, integer *init,
doublereal *phir, doublereal *phii, doublereal *zeta1r, doublereal *
zeta1i, doublereal *zeta2r, doublereal *zeta2i, doublereal *sumr,
doublereal *sumi, doublereal *cwrkr, doublereal *cwrki)
{
/* Initialized data */
static doublereal zeror = 0.;
static doublereal zeroi = 0.;
static doublereal coner = 1.;
static doublereal conei = 0.;
static doublereal con[2] = { .398942280401432678,1.25331413731550025 };
static doublereal c__[120] = { 1.,-.208333333333333333,.125,
.334201388888888889,-.401041666666666667,.0703125,
-1.02581259645061728,1.84646267361111111,-.8912109375,.0732421875,
4.66958442342624743,-11.2070026162229938,8.78912353515625,
-2.3640869140625,.112152099609375,-28.2120725582002449,
84.6362176746007346,-91.8182415432400174,42.5349987453884549,
-7.3687943594796317,.227108001708984375,212.570130039217123,
-765.252468141181642,1059.99045252799988,-699.579627376132541,
218.19051174421159,-26.4914304869515555,.572501420974731445,
-1919.457662318407,8061.72218173730938,-13586.5500064341374,
11655.3933368645332,-5305.64697861340311,1200.90291321635246,
-108.090919788394656,1.7277275025844574,20204.2913309661486,
-96980.5983886375135,192547.001232531532,-203400.177280415534,
122200.46498301746,-41192.6549688975513,7109.51430248936372,
-493.915304773088012,6.07404200127348304,-242919.187900551333,
1311763.6146629772,-2998015.91853810675,3763271.297656404,
-2813563.22658653411,1268365.27332162478,-331645.172484563578,
45218.7689813627263,-2499.83048181120962,24.3805296995560639,
3284469.85307203782,-19706819.1184322269,50952602.4926646422,
-74105148.2115326577,66344512.2747290267,-37567176.6607633513,
13288767.1664218183,-2785618.12808645469,308186.404612662398,
-13886.0897537170405,110.017140269246738,-49329253.664509962,
325573074.185765749,-939462359.681578403,1553596899.57058006,
-1621080552.10833708,1106842816.82301447,-495889784.275030309,
142062907.797533095,-24474062.7257387285,2243768.17792244943,
-84005.4336030240853,551.335896122020586,814789096.118312115,
-5866481492.05184723,18688207509.2958249,-34632043388.1587779,
41280185579.753974,-33026599749.8007231,17954213731.1556001,
-6563293792.61928433,1559279864.87925751,-225105661.889415278,
17395107.5539781645,-549842.327572288687,3038.09051092238427,
-14679261247.6956167,114498237732.02581,-399096175224.466498,
819218669548.577329,-1098375156081.22331,1008158106865.38209,
-645364869245.376503,287900649906.150589,-87867072178.0232657,
17634730606.8349694,-2167164983.22379509,143157876.718888981,
-3871833.44257261262,18257.7554742931747,286464035717.679043,
-2406297900028.50396,9109341185239.89896,-20516899410934.4374,
30565125519935.3206,-31667088584785.1584,23348364044581.8409,
-12320491305598.2872,4612725780849.13197,-1196552880196.1816,
205914503232.410016,-21822927757.5292237,1247009293.51271032,
-29188388.1222208134,118838.426256783253 };
/* System generated locals */
integer i__1;
doublereal d__1, d__2;
/* Builtin functions */
double log(doublereal);
/* Local variables */
static integer i__, j, k, l;
static doublereal ac, si, ti, sr, tr, t2i, t2r, rfn, sri, sti, zni, srr,
str, znr;
static integer idum;
extern /* Subroutine */ int zdiv_(doublereal *, doublereal *, doublereal *
, doublereal *, doublereal *, doublereal *);
static doublereal test, crfni, crfnr;
extern /* Subroutine */ int azlog_(doublereal *, doublereal *, doublereal
*, doublereal *, integer *);
extern doublereal d1mach_(integer *);
extern /* Subroutine */ int azsqrt_(doublereal *, doublereal *,
doublereal *, doublereal *);
/* ***BEGIN PROLOGUE ZUNIK */
/* ***REFER TO ZBESI,ZBESK */
/* ZUNIK COMPUTES PARAMETERS FOR THE UNIFORM ASYMPTOTIC */
/* EXPANSIONS OF THE I AND K FUNCTIONS ON IKFLG= 1 OR 2 */
/* RESPECTIVELY BY */
/* W(FNU,ZR) = PHI*EXP(ZETA)*SUM */
/* WHERE ZETA=-ZETA1 + ZETA2 OR */
/* ZETA1 - ZETA2 */
/* THE FIRST CALL MUST HAVE INIT=0. SUBSEQUENT CALLS WITH THE */
/* SAME ZR AND FNU WILL RETURN THE I OR K FUNCTION ON IKFLG= */
/* 1 OR 2 WITH NO CHANGE IN INIT. CWRK IS A COMPLEX WORK */
/* ARRAY. IPMTR=0 COMPUTES ALL PARAMETERS. IPMTR=1 COMPUTES PHI, */
/* ZETA1,ZETA2. */
/* ***ROUTINES CALLED ZDIV,AZLOG,AZSQRT,D1MACH */
/* ***END PROLOGUE ZUNIK */
/* COMPLEX CFN,CON,CONE,CRFN,CWRK,CZERO,PHI,S,SR,SUM,T,T2,ZETA1, */
/* *ZETA2,ZN,ZR */
/* Parameter adjustments */
--cwrki;
--cwrkr;
/* Function Body */
if (*init != 0) {
goto L40;
}
/* ----------------------------------------------------------------------- */
/* INITIALIZE ALL VARIABLES */
/* ----------------------------------------------------------------------- */
rfn = 1. / *fnu;
/* ----------------------------------------------------------------------- */
/* OVERFLOW TEST (ZR/FNU TOO SMALL) */
/* ----------------------------------------------------------------------- */
test = d1mach_(&c__1) * 1e3;
ac = *fnu * test;
if (abs(*zrr) > ac || abs(*zri) > ac) {
goto L15;
}
*zeta1r = (d__1 = log(test), abs(d__1)) * 2. + *fnu;
*zeta1i = 0.;
*zeta2r = *fnu;
*zeta2i = 0.;
*phir = 1.;
*phii = 0.;
return 0;
L15:
tr = *zrr * rfn;
ti = *zri * rfn;
sr = coner + (tr * tr - ti * ti);
si = conei + (tr * ti + ti * tr);
azsqrt_(&sr, &si, &srr, &sri);
str = coner + srr;
sti = conei + sri;
zdiv_(&str, &sti, &tr, &ti, &znr, &zni);
azlog_(&znr, &zni, &str, &sti, &idum);
*zeta1r = *fnu * str;
*zeta1i = *fnu * sti;
*zeta2r = *fnu * srr;
*zeta2i = *fnu * sri;
zdiv_(&coner, &conei, &srr, &sri, &tr, &ti);
srr = tr * rfn;
sri = ti * rfn;
azsqrt_(&srr, &sri, &cwrkr[16], &cwrki[16]);
*phir = cwrkr[16] * con[*ikflg - 1];
*phii = cwrki[16] * con[*ikflg - 1];
if (*ipmtr != 0) {
return 0;
}
zdiv_(&coner, &conei, &sr, &si, &t2r, &t2i);
cwrkr[1] = coner;
cwrki[1] = conei;
crfnr = coner;
crfni = conei;
ac = 1.;
l = 1;
for (k = 2; k <= 15; ++k) {
sr = zeror;
si = zeroi;
i__1 = k;
for (j = 1; j <= i__1; ++j) {
++l;
str = sr * t2r - si * t2i + c__[l - 1];
si = sr * t2i + si * t2r;
sr = str;
/* L10: */
}
str = crfnr * srr - crfni * sri;
crfni = crfnr * sri + crfni * srr;
crfnr = str;
cwrkr[k] = crfnr * sr - crfni * si;
cwrki[k] = crfnr * si + crfni * sr;
ac *= rfn;
test = (d__1 = cwrkr[k], abs(d__1)) + (d__2 = cwrki[k], abs(d__2));
if (ac < *tol && test < *tol) {
goto L30;
}
/* L20: */
}
k = 15;
L30:
*init = k;
L40:
if (*ikflg == 2) {
goto L60;
}
/* ----------------------------------------------------------------------- */
/* COMPUTE SUM FOR THE I FUNCTION */
/* ----------------------------------------------------------------------- */
sr = zeror;
si = zeroi;
i__1 = *init;
for (i__ = 1; i__ <= i__1; ++i__) {
sr += cwrkr[i__];
si += cwrki[i__];
/* L50: */
}
*sumr = sr;
*sumi = si;
*phir = cwrkr[16] * con[0];
*phii = cwrki[16] * con[0];
return 0;
L60:
/* ----------------------------------------------------------------------- */
/* COMPUTE SUM FOR THE K FUNCTION */
/* ----------------------------------------------------------------------- */
sr = zeror;
si = zeroi;
tr = coner;
i__1 = *init;
for (i__ = 1; i__ <= i__1; ++i__) {
sr += tr * cwrkr[i__];
si += tr * cwrki[i__];
tr = -tr;
/* L70: */
}
*sumr = sr;
*sumi = si;
*phir = cwrkr[16] * con[1];
*phii = cwrki[16] * con[1];
return 0;
} /* zunik_ */
| /* zunik.f -- translated by f2c (version 20190311).
You must link the resulting object file with libf2c:
on Microsoft Windows system, link with libf2c.lib;
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
or, if you install libf2c.a in a standard place, with -lf2c -lm
-- in that order, at the end of the command line, as in
cc *.o -lf2c -lm
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
http://www.netlib.org/f2c/libf2c.zip
*/
#include "f2c.h"
/* Table of constant values */
static integer c__1 = 1;
/* Subroutine */ int FUNC_0(doublereal *zrr, doublereal *zri, doublereal *fnu,
integer *ikflg, integer *ipmtr, doublereal *tol, integer *VAR_0,
doublereal *phir, doublereal *phii, doublereal *zeta1r, doublereal *
zeta1i, doublereal *zeta2r, doublereal *VAR_1, doublereal *sumr,
doublereal *VAR_2, doublereal *VAR_3, doublereal *cwrki)
{
/* Initialized data */
static doublereal zeror = 0.;
static doublereal zeroi = 0.;
static doublereal coner = 1.;
static doublereal conei = 0.;
static doublereal VAR_4[2] = { .398942280401432678,1.25331413731550025 };
static doublereal c__[120] = { 1.,-.208333333333333333,.125,
.334201388888888889,-.401041666666666667,.0703125,
-1.02581259645061728,1.84646267361111111,-.8912109375,.0732421875,
4.66958442342624743,-11.2070026162229938,8.78912353515625,
-2.3640869140625,.112152099609375,-28.2120725582002449,
84.6362176746007346,-91.8182415432400174,42.5349987453884549,
-7.3687943594796317,.227108001708984375,212.570130039217123,
-765.252468141181642,1059.99045252799988,-699.579627376132541,
218.19051174421159,-26.4914304869515555,.572501420974731445,
-1919.457662318407,8061.72218173730938,-13586.5500064341374,
11655.3933368645332,-5305.64697861340311,1200.90291321635246,
-108.090919788394656,1.7277275025844574,20204.2913309661486,
-96980.5983886375135,192547.001232531532,-203400.177280415534,
122200.46498301746,-41192.6549688975513,7109.51430248936372,
-493.915304773088012,6.07404200127348304,-242919.187900551333,
1311763.6146629772,-2998015.91853810675,3763271.297656404,
-2813563.22658653411,1268365.27332162478,-331645.172484563578,
45218.7689813627263,-2499.83048181120962,24.3805296995560639,
3284469.85307203782,-19706819.1184322269,50952602.4926646422,
-74105148.2115326577,66344512.2747290267,-37567176.6607633513,
13288767.1664218183,-2785618.12808645469,308186.404612662398,
-13886.0897537170405,110.017140269246738,-49329253.664509962,
325573074.185765749,-939462359.681578403,1553596899.57058006,
-1621080552.10833708,1106842816.82301447,-495889784.275030309,
142062907.797533095,-24474062.7257387285,2243768.17792244943,
-84005.4336030240853,551.335896122020586,814789096.118312115,
-5866481492.05184723,18688207509.2958249,-34632043388.1587779,
41280185579.753974,-33026599749.8007231,17954213731.1556001,
-6563293792.61928433,1559279864.87925751,-225105661.889415278,
17395107.5539781645,-549842.327572288687,3038.09051092238427,
-14679261247.6956167,114498237732.02581,-399096175224.466498,
819218669548.577329,-1098375156081.22331,1008158106865.38209,
-645364869245.376503,287900649906.150589,-87867072178.0232657,
17634730606.8349694,-2167164983.22379509,143157876.718888981,
-3871833.44257261262,18257.7554742931747,286464035717.679043,
-2406297900028.50396,9109341185239.89896,-20516899410934.4374,
30565125519935.3206,-31667088584785.1584,23348364044581.8409,
-12320491305598.2872,4612725780849.13197,-1196552880196.1816,
205914503232.410016,-21822927757.5292237,1247009293.51271032,
-29188388.1222208134,118838.426256783253 };
/* System generated locals */
integer VAR_5;
doublereal d__1, d__2;
/* Builtin functions */
double log(doublereal);
/* Local variables */
static integer i__, j, k, l;
static doublereal VAR_6, si, ti, sr, tr, t2i, t2r, rfn, sri, sti, zni, srr,
str, znr;
static integer idum;
extern /* Subroutine */ int zdiv_(doublereal *, doublereal *, doublereal *
, doublereal *, doublereal *, doublereal *);
static doublereal test, crfni, crfnr;
extern /* Subroutine */ int azlog_(doublereal *, doublereal *, doublereal
*, doublereal *, integer *);
extern doublereal d1mach_(integer *);
extern /* Subroutine */ int azsqrt_(doublereal *, doublereal *,
doublereal *, doublereal *);
/* ***BEGIN PROLOGUE ZUNIK */
/* ***REFER TO ZBESI,ZBESK */
/* ZUNIK COMPUTES PARAMETERS FOR THE UNIFORM ASYMPTOTIC */
/* EXPANSIONS OF THE I AND K FUNCTIONS ON IKFLG= 1 OR 2 */
/* RESPECTIVELY BY */
/* W(FNU,ZR) = PHI*EXP(ZETA)*SUM */
/* WHERE ZETA=-ZETA1 + ZETA2 OR */
/* ZETA1 - ZETA2 */
/* THE FIRST CALL MUST HAVE INIT=0. SUBSEQUENT CALLS WITH THE */
/* SAME ZR AND FNU WILL RETURN THE I OR K FUNCTION ON IKFLG= */
/* 1 OR 2 WITH NO CHANGE IN INIT. CWRK IS A COMPLEX WORK */
/* ARRAY. IPMTR=0 COMPUTES ALL PARAMETERS. IPMTR=1 COMPUTES PHI, */
/* ZETA1,ZETA2. */
/* ***ROUTINES CALLED ZDIV,AZLOG,AZSQRT,D1MACH */
/* ***END PROLOGUE ZUNIK */
/* COMPLEX CFN,CON,CONE,CRFN,CWRK,CZERO,PHI,S,SR,SUM,T,T2,ZETA1, */
/* *ZETA2,ZN,ZR */
/* Parameter adjustments */
--cwrki;
--VAR_3;
/* Function Body */
if (*VAR_0 != 0) {
goto L40;
}
/* ----------------------------------------------------------------------- */
/* INITIALIZE ALL VARIABLES */
/* ----------------------------------------------------------------------- */
rfn = 1. / *fnu;
/* ----------------------------------------------------------------------- */
/* OVERFLOW TEST (ZR/FNU TOO SMALL) */
/* ----------------------------------------------------------------------- */
test = d1mach_(&c__1) * 1e3;
VAR_6 = *fnu * test;
if (abs(*zrr) > VAR_6 || abs(*zri) > VAR_6) {
goto L15;
}
*zeta1r = (d__1 = log(test), abs(d__1)) * 2. + *fnu;
*zeta1i = 0.;
*zeta2r = *fnu;
*VAR_1 = 0.;
*phir = 1.;
*phii = 0.;
return 0;
L15:
tr = *zrr * rfn;
ti = *zri * rfn;
sr = coner + (tr * tr - ti * ti);
si = conei + (tr * ti + ti * tr);
azsqrt_(&sr, &si, &srr, &sri);
str = coner + srr;
sti = conei + sri;
zdiv_(&str, &sti, &tr, &ti, &znr, &zni);
azlog_(&znr, &zni, &str, &sti, &idum);
*zeta1r = *fnu * str;
*zeta1i = *fnu * sti;
*zeta2r = *fnu * srr;
*VAR_1 = *fnu * sri;
zdiv_(&coner, &conei, &srr, &sri, &tr, &ti);
srr = tr * rfn;
sri = ti * rfn;
azsqrt_(&srr, &sri, &VAR_3[16], &cwrki[16]);
*phir = VAR_3[16] * VAR_4[*ikflg - 1];
*phii = cwrki[16] * VAR_4[*ikflg - 1];
if (*ipmtr != 0) {
return 0;
}
zdiv_(&coner, &conei, &sr, &si, &t2r, &t2i);
VAR_3[1] = coner;
cwrki[1] = conei;
crfnr = coner;
crfni = conei;
VAR_6 = 1.;
l = 1;
for (k = 2; k <= 15; ++k) {
sr = zeror;
si = zeroi;
VAR_5 = k;
for (j = 1; j <= VAR_5; ++j) {
++l;
str = sr * t2r - si * t2i + c__[l - 1];
si = sr * t2i + si * t2r;
sr = str;
/* L10: */
}
str = crfnr * srr - crfni * sri;
crfni = crfnr * sri + crfni * srr;
crfnr = str;
VAR_3[k] = crfnr * sr - crfni * si;
cwrki[k] = crfnr * si + crfni * sr;
VAR_6 *= rfn;
test = (d__1 = VAR_3[k], abs(d__1)) + (d__2 = cwrki[k], abs(d__2));
if (VAR_6 < *tol && test < *tol) {
goto L30;
}
/* L20: */
}
k = 15;
L30:
*VAR_0 = k;
L40:
if (*ikflg == 2) {
goto L60;
}
/* ----------------------------------------------------------------------- */
/* COMPUTE SUM FOR THE I FUNCTION */
/* ----------------------------------------------------------------------- */
sr = zeror;
si = zeroi;
VAR_5 = *VAR_0;
for (i__ = 1; i__ <= VAR_5; ++i__) {
sr += VAR_3[i__];
si += cwrki[i__];
/* L50: */
}
*sumr = sr;
*VAR_2 = si;
*phir = VAR_3[16] * VAR_4[0];
*phii = cwrki[16] * VAR_4[0];
return 0;
L60:
/* ----------------------------------------------------------------------- */
/* COMPUTE SUM FOR THE K FUNCTION */
/* ----------------------------------------------------------------------- */
sr = zeror;
si = zeroi;
tr = coner;
VAR_5 = *VAR_0;
for (i__ = 1; i__ <= VAR_5; ++i__) {
sr += tr * VAR_3[i__];
si += tr * cwrki[i__];
tr = -tr;
/* L70: */
}
*sumr = sr;
*VAR_2 = si;
*phir = VAR_3[16] * VAR_4[1];
*phii = cwrki[16] * VAR_4[1];
return 0;
} /* zunik_ */
| 0.091397 | {'FUNC_0': 'zunik_', 'VAR_0': 'init', 'VAR_1': 'zeta2i', 'VAR_2': 'sumi', 'VAR_3': 'cwrkr', 'VAR_4': 'con', 'VAR_5': 'i__1', 'VAR_6': 'ac'} |
/******************************************************************************
* Copyright (c) 2019 - 2020 Xilinx, Inc. All rights reserved.
* SPDX-License-Identifier: MIT
******************************************************************************/
#ifndef XPM_DEVICE_IDLE_H_
#define XPM_DEVICE_IDLE_H_
#include "xparameters.h"
#include "xpm_node.h"
#include "xpm_device.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct XPmDevice_SoftResetInfo {
u32 DeviceId;
XStatus (*IdleHook)(u16 DeviceId, u32 BaseAddress); /**< Hook function for idling */
u16 IdleHookArgs;
} XPmDevice_SoftResetInfo;
/* Define the XILPM device macro based on canonical defination. */
/* XILPM_USB_0 */
#if (defined(XPAR_XUSBPSU_0_DEVICE_ID) && \
(XPAR_XUSBPSU_0_BASEADDR == 0xFE200000U))
#define XILPM_USB_0 XPAR_XUSBPSU_0_DEVICE_ID
#endif
/* XILPM_QSPI_0 */
#if (defined(XPAR_XQSPIPSU_0_DEVICE_ID) && \
(XPAR_XQSPIPSU_0_BASEADDR == 0xF1030000U))
#define XILPM_QSPI_0 XPAR_XQSPIPSU_0_DEVICE_ID
#endif
/* XILPM_OSPI_0 */
#if (defined(XPAR_XOSPIPSV_0_DEVICE_ID) && \
(XPAR_XOSPIPSV_0_BASEADDR == 0xF1010000U))
#define XILPM_OSPI_0 XPAR_XOSPIPSV_0_DEVICE_ID
#endif
/* XILPM_SD_0 and XILPM_SD_1 */
#if (defined(XPAR_XSDPS_0_DEVICE_ID))
#if (XPAR_XSDPS_0_BASEADDR == 0xF1040000U)
#define XILPM_SD_0 XPAR_XSDPS_0_DEVICE_ID
#elif (XPAR_XSDPS_0_BASEADDR == 0xF1050000U)
#define XILPM_SD_1 XPAR_XSDPS_0_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XSDPS_1_DEVICE_ID))
#if (XPAR_XSDPS_1_BASEADDR == 0xF1040000U)
#define XILPM_SD_0 XPAR_XSDPS_1_DEVICE_ID
#elif (XPAR_XSDPS_1_BASEADDR == 0xF1050000U)
#define XILPM_SD_1 XPAR_XSDPS_1_DEVICE_ID
#endif
#endif
/* XILPM_ETH_0 and XILPM_ETH_1 */
#if (defined(XPAR_XEMACPS_0_DEVICE_ID))
#if (XPAR_XEMACPS_0_BASEADDR == 0xFF0C0000U)
#define XILPM_ETH_0 XPAR_XEMACPS_0_DEVICE_ID
#elif (XPAR_XEMACPS_0_BASEADDR == 0xFF0D0000U)
#define XILPM_ETH_1 XPAR_XEMACPS_0_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XEMACPS_1_DEVICE_ID))
#if (XPAR_XEMACPS_1_BASEADDR == 0xFF0C0000U)
#define XILPM_ETH_0 XPAR_XEMACPS_1_DEVICE_ID
#elif (XPAR_XEMACPS_1_BASEADDR == 0xFF0D0000U)
#define XILPM_ETH_1 XPAR_XEMACPS_1_DEVICE_ID
#endif
#endif
/* XILPM_ZDMA_0 to XILPM_ZDMA_7 */
#if (defined(XPAR_XZDMA_0_DEVICE_ID))
#if (XPAR_XZDMA_0_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFA90000U)
#define XILPM_ZDMA_1 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFAE0000U)
#define XILPM_ZDMA_6 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_0_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XZDMA_1_DEVICE_ID))
#if (XPAR_XZDMA_1_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFA90000U)
#define XILPM_ZDMA_1 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFAE0000U)
#define XILPM_ZDMA_6 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_1_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XZDMA_2_DEVICE_ID))
#if (XPAR_XZDMA_2_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFA90000U)
#define XILPM_ZDMA_1 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFAE0000U)
#define XILPM_ZDMA_6 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_2_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XZDMA_3_DEVICE_ID))
#if (XPAR_XZDMA_3_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFA90000U)
#define XILPM_ZDMA_1 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFAE0000U)
#define XILPM_ZDMA_6 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_3_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XZDMA_4_DEVICE_ID))
#if (XPAR_XZDMA_4_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFA90000U)
#define XILPM_ZDMA_1 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFAE0000U)
#define XILPM_ZDMA_6 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_4_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XZDMA_5_DEVICE_ID))
#if (XPAR_XZDMA_5_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_5_DEVICE_ID
#elif (XPAR_XZDMA_5_BASEADDR == 0xFFA90000U)
#define XILPM_ZDMA_1 XPAR_XZDMA_5_DEVICE_ID
#elif (XPAR_XZDMA_5_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_5_DEVICE_ID
#elif (XPAR_XZDMA_5_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_5_DEVICE_ID
#elif (XPAR_XZDMA_5_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_5_DEVICE_ID
#elif (XPAR_XZDMA_5_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_5_DEVICE_ID
#elif (XPAR_XZDMA_5_BASEADDR == 0xFFAE0000U)
#define XILPM_ZDMA_6 XPAR_XZDMA_5_DEVICE_ID
#elif (XPAR_XZDMA_5_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_5_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XZDMA_6_DEVICE_ID))
#if (XPAR_XZDMA_6_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_6_DEVICE_ID
#elif (XPAR_XZDMA_6_BASEADDR == 0xFFA90000U)
#define XILPM_ZDMA_1 XPAR_XZDMA_6_DEVICE_ID
#elif (XPAR_XZDMA_6_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_6_DEVICE_ID
#elif (XPAR_XZDMA_6_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_6_DEVICE_ID
#elif (XPAR_XZDMA_6_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_6_DEVICE_ID
#elif (XPAR_XZDMA_6_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_6_DEVICE_ID
#elif (XPAR_XZDMA_6_BASEADDR == 0xFFAE0000U)
#define XILPM_ZDMA_6 XPAR_XZDMA_6_DEVICE_ID
#elif (XPAR_XZDMA_6_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_6_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XZDMA_7_DEVICE_ID))
#if (XPAR_XZDMA_7_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFA90000U)
#define XILPM_ZDMA_1 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFAE0000U)
#define XILPM_ZDMA_6 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_7_DEVICE_ID
#endif
#endif
#if defined(XILPM_QSPI_0)
#include "xqspipsu.h"
XStatus NodeQspiIdle(u16 DeviceId, u32 BaseAddress);
#endif
#if defined(XILPM_OSPI_0)
#include "xospipsv.h"
XStatus NodeOspiIdle(u16 DeviceId, u32 BaseAddress);
#endif
#if defined(XILPM_SD_0) || defined(XILPM_SD_1)
#include "xsdps.h"
XStatus NodeSdioIdle(u16 DeviceId, u32 BaseAddress);
#endif
#if defined(XILPM_USB_0)
#include "xusbpsu.h"
XStatus NodeUsbIdle(u16 DeviceId, u32 BaseAddress);
#endif
#if defined(XILPM_ETH_0) || defined(XILPM_ETH_1)
#include "xemacps_hw.h"
XStatus NodeGemIdle(u16 DeviceId, u32 BaseAddress);
#endif
#if (defined(XILPM_ZDMA_0) || \
defined(XILPM_ZDMA_1) || \
defined(XILPM_ZDMA_2) || \
defined(XILPM_ZDMA_3) || \
defined(XILPM_ZDMA_4) || \
defined(XILPM_ZDMA_5) || \
defined(XILPM_ZDMA_6) || \
defined(XILPM_ZDMA_7))
#include "xzdma_hw.h"
XStatus NodeZdmaIdle(u16 DeviceId, u32 BaseAddr);
#endif
XStatus XPmDevice_SoftResetIdle(const XPm_Device *Device, const u32 IdleReq);
#ifdef __cplusplus
}
#endif
#endif /* XPM_DEVICE_IDLE_H_ */
| /******************************************************************************
* Copyright (c) 2019 - 2020 Xilinx, Inc. All rights reserved.
* SPDX-License-Identifier: MIT
******************************************************************************/
#ifndef VAR_0
#define VAR_0
#include "IMPORT_0"
#include "xpm_node.h"
#include "IMPORT_1"
#ifdef VAR_1
extern "C" {
#endif
typedef struct CLASS_0 {
u32 VAR_2;
XStatus (*IdleHook)(u16 VAR_2, u32 VAR_3); /**< Hook function for idling */
u16 VAR_4;
} ID_0;
/* Define the XILPM device macro based on canonical defination. */
/* XILPM_USB_0 */
#if (defined(XPAR_XUSBPSU_0_DEVICE_ID) && \
(XPAR_XUSBPSU_0_BASEADDR == 0xFE200000U))
#define XILPM_USB_0 XPAR_XUSBPSU_0_DEVICE_ID
#endif
/* XILPM_QSPI_0 */
#if (defined(VAR_5) && \
(XPAR_XQSPIPSU_0_BASEADDR == 0xF1030000U))
#define XILPM_QSPI_0 XPAR_XQSPIPSU_0_DEVICE_ID
#endif
/* XILPM_OSPI_0 */
#if (defined(VAR_6) && \
(XPAR_XOSPIPSV_0_BASEADDR == 0xF1010000U))
#define VAR_7 XPAR_XOSPIPSV_0_DEVICE_ID
#endif
/* XILPM_SD_0 and XILPM_SD_1 */
#if (defined(VAR_8))
#if (VAR_9 == 0xF1040000U)
#define XILPM_SD_0 XPAR_XSDPS_0_DEVICE_ID
#elif (VAR_9 == 0xF1050000U)
#define XILPM_SD_1 XPAR_XSDPS_0_DEVICE_ID
#endif
#endif
#if (defined(VAR_10))
#if (VAR_11 == 0xF1040000U)
#define XILPM_SD_0 XPAR_XSDPS_1_DEVICE_ID
#elif (VAR_11 == 0xF1050000U)
#define XILPM_SD_1 XPAR_XSDPS_1_DEVICE_ID
#endif
#endif
/* XILPM_ETH_0 and XILPM_ETH_1 */
#if (defined(VAR_12))
#if (VAR_13 == 0xFF0C0000U)
#define XILPM_ETH_0 XPAR_XEMACPS_0_DEVICE_ID
#elif (VAR_13 == 0xFF0D0000U)
#define VAR_14 XPAR_XEMACPS_0_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XEMACPS_1_DEVICE_ID))
#if (XPAR_XEMACPS_1_BASEADDR == 0xFF0C0000U)
#define XILPM_ETH_0 XPAR_XEMACPS_1_DEVICE_ID
#elif (XPAR_XEMACPS_1_BASEADDR == 0xFF0D0000U)
#define VAR_14 XPAR_XEMACPS_1_DEVICE_ID
#endif
#endif
/* XILPM_ZDMA_0 to XILPM_ZDMA_7 */
#if (defined(VAR_15))
#if (XPAR_XZDMA_0_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFA90000U)
#define VAR_16 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFAE0000U)
#define VAR_17 XPAR_XZDMA_0_DEVICE_ID
#elif (XPAR_XZDMA_0_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_0_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XZDMA_1_DEVICE_ID))
#if (XPAR_XZDMA_1_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFA90000U)
#define VAR_16 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFAE0000U)
#define VAR_17 XPAR_XZDMA_1_DEVICE_ID
#elif (XPAR_XZDMA_1_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_1_DEVICE_ID
#endif
#endif
#if (defined(VAR_18))
#if (XPAR_XZDMA_2_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFA90000U)
#define VAR_16 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFAE0000U)
#define VAR_17 XPAR_XZDMA_2_DEVICE_ID
#elif (XPAR_XZDMA_2_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_2_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XZDMA_3_DEVICE_ID))
#if (XPAR_XZDMA_3_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFA90000U)
#define VAR_16 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFAE0000U)
#define VAR_17 XPAR_XZDMA_3_DEVICE_ID
#elif (XPAR_XZDMA_3_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_3_DEVICE_ID
#endif
#endif
#if (defined(XPAR_XZDMA_4_DEVICE_ID))
#if (XPAR_XZDMA_4_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFA90000U)
#define VAR_16 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFAE0000U)
#define VAR_17 XPAR_XZDMA_4_DEVICE_ID
#elif (XPAR_XZDMA_4_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_4_DEVICE_ID
#endif
#endif
#if (defined(VAR_19))
#if (VAR_20 == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_5_DEVICE_ID
#elif (VAR_20 == 0xFFA90000U)
#define VAR_16 XPAR_XZDMA_5_DEVICE_ID
#elif (VAR_20 == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_5_DEVICE_ID
#elif (VAR_20 == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_5_DEVICE_ID
#elif (VAR_20 == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_5_DEVICE_ID
#elif (VAR_20 == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_5_DEVICE_ID
#elif (VAR_20 == 0xFFAE0000U)
#define VAR_17 XPAR_XZDMA_5_DEVICE_ID
#elif (VAR_20 == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_5_DEVICE_ID
#endif
#endif
#if (defined(VAR_21))
#if (VAR_22 == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_6_DEVICE_ID
#elif (VAR_22 == 0xFFA90000U)
#define VAR_16 XPAR_XZDMA_6_DEVICE_ID
#elif (VAR_22 == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_6_DEVICE_ID
#elif (VAR_22 == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_6_DEVICE_ID
#elif (VAR_22 == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_6_DEVICE_ID
#elif (VAR_22 == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_6_DEVICE_ID
#elif (VAR_22 == 0xFFAE0000U)
#define VAR_17 XPAR_XZDMA_6_DEVICE_ID
#elif (VAR_22 == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_6_DEVICE_ID
#endif
#endif
#if (defined(VAR_23))
#if (XPAR_XZDMA_7_BASEADDR == 0xFFA80000U)
#define XILPM_ZDMA_0 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFA90000U)
#define VAR_16 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFAA0000U)
#define XILPM_ZDMA_2 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFAB0000U)
#define XILPM_ZDMA_3 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFAC0000U)
#define XILPM_ZDMA_4 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFAD0000U)
#define XILPM_ZDMA_5 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFAE0000U)
#define VAR_17 XPAR_XZDMA_7_DEVICE_ID
#elif (XPAR_XZDMA_7_BASEADDR == 0xFFAF0000U)
#define XILPM_ZDMA_7 XPAR_XZDMA_7_DEVICE_ID
#endif
#endif
#if defined(XILPM_QSPI_0)
#include "IMPORT_2"
XStatus NodeQspiIdle(u16 VAR_2, u32 VAR_3);
#endif
#if defined(VAR_7)
#include "xospipsv.h"
XStatus FUNC_0(u16 VAR_2, u32 VAR_3);
#endif
#if defined(XILPM_SD_0) || defined(XILPM_SD_1)
#include "IMPORT_3"
XStatus NodeSdioIdle(u16 VAR_2, u32 VAR_3);
#endif
#if defined(XILPM_USB_0)
#include "xusbpsu.h"
XStatus FUNC_1(u16 VAR_2, u32 VAR_3);
#endif
#if defined(XILPM_ETH_0) || defined(VAR_14)
#include "IMPORT_4"
XStatus NodeGemIdle(u16 VAR_2, u32 VAR_3);
#endif
#if (defined(XILPM_ZDMA_0) || \
defined(VAR_16) || \
defined(XILPM_ZDMA_2) || \
defined(XILPM_ZDMA_3) || \
defined(XILPM_ZDMA_4) || \
defined(XILPM_ZDMA_5) || \
defined(VAR_17) || \
defined(XILPM_ZDMA_7))
#include "xzdma_hw.h"
XStatus FUNC_2(u16 VAR_2, u32 VAR_24);
#endif
XStatus FUNC_3(const CLASS_1 *Device, const u32 IdleReq);
#ifdef VAR_1
}
#endif
#endif /* XPM_DEVICE_IDLE_H_ */
| 0.491241 | {'VAR_0': 'XPM_DEVICE_IDLE_H_', 'IMPORT_0': 'xparameters.h', 'IMPORT_1': 'xpm_device.h', 'VAR_1': '__cplusplus', 'CLASS_0': 'XPmDevice_SoftResetInfo', 'ID_0': 'XPmDevice_SoftResetInfo', 'VAR_2': 'DeviceId', 'VAR_3': 'BaseAddress', 'VAR_4': 'IdleHookArgs', 'VAR_5': 'XPAR_XQSPIPSU_0_DEVICE_ID', 'VAR_6': 'XPAR_XOSPIPSV_0_DEVICE_ID', 'VAR_7': 'XILPM_OSPI_0', 'VAR_8': 'XPAR_XSDPS_0_DEVICE_ID', 'VAR_9': 'XPAR_XSDPS_0_BASEADDR', 'VAR_10': 'XPAR_XSDPS_1_DEVICE_ID', 'VAR_11': 'XPAR_XSDPS_1_BASEADDR', 'VAR_12': 'XPAR_XEMACPS_0_DEVICE_ID', 'VAR_13': 'XPAR_XEMACPS_0_BASEADDR', 'VAR_14': 'XILPM_ETH_1', 'VAR_15': 'XPAR_XZDMA_0_DEVICE_ID', 'VAR_16': 'XILPM_ZDMA_1', 'VAR_17': 'XILPM_ZDMA_6', 'VAR_18': 'XPAR_XZDMA_2_DEVICE_ID', 'VAR_19': 'XPAR_XZDMA_5_DEVICE_ID', 'VAR_20': 'XPAR_XZDMA_5_BASEADDR', 'VAR_21': 'XPAR_XZDMA_6_DEVICE_ID', 'VAR_22': 'XPAR_XZDMA_6_BASEADDR', 'VAR_23': 'XPAR_XZDMA_7_DEVICE_ID', 'IMPORT_2': 'xqspipsu.h', 'FUNC_0': 'NodeOspiIdle', 'IMPORT_3': 'xsdps.h', 'FUNC_1': 'NodeUsbIdle', 'IMPORT_4': 'xemacps_hw.h', 'FUNC_2': 'NodeZdmaIdle', 'VAR_24': 'BaseAddr', 'FUNC_3': 'XPmDevice_SoftResetIdle', 'CLASS_1': 'XPm_Device'} |
#include "StackHelper.h"
#include <core/Stack_.h>
#include <dataTypes/stack_p.h>
size_t stack_get_size(Stack stack)
{
return stack_size(stack->entries);
} | #include "IMPORT_0"
#include <IMPORT_1>
#include <dataTypes/stack_p.h>
size_t FUNC_0(CLASS_0 VAR_0)
{
return stack_size(VAR_0->VAR_1);
} | 0.748406 | {'IMPORT_0': 'StackHelper.h', 'IMPORT_1': 'core/Stack_.h', 'FUNC_0': 'stack_get_size', 'CLASS_0': 'Stack', 'VAR_0': 'stack', 'VAR_1': 'entries'} |
/*
* end_keymenu - free resources associated with keymenu display cache
*/
void
end_keymenu()
{
int i;
for(i = 0; i < 12; i++){
if(last_time_buf[i].name)
fs_give((void **)&last_time_buf[i].name);
if(last_time_buf[i].label)
fs_give((void **)&last_time_buf[i].label);
}
} | /*
* end_keymenu - free resources associated with keymenu display cache
*/
void
FUNC_0()
{
int i;
for(i = 0; i < 12; i++){
if(last_time_buf[i].VAR_0)
FUNC_1((void **)&last_time_buf[i].VAR_0);
if(last_time_buf[i].label)
FUNC_1((void **)&last_time_buf[i].label);
}
} | 0.556632 | {'FUNC_0': 'end_keymenu', 'VAR_0': 'name', 'FUNC_1': 'fs_give'} |
/// <introduction>
/// dynamic array
/// implemented by array
/// </introduction>
#pragma once
#include <stdint.h>
#include "TypeTraits.h"
template<typename T>
class DynamicArray
{
private:
T* buffer_;
size_t capacity_;
size_t size_;
public:
DynamicArray() : buffer_(nullptr), size_(0), capacity_(0) {};
DynamicArray(const size_t& capacity);
DynamicArray(const size_t& capacity, const T& default_value);
DynamicArray(const DynamicArray& other);
DynamicArray(DynamicArray&& other);
~DynamicArray();
DynamicArray& operator =(const DynamicArray& array);
DynamicArray& operator =(DynamicArray&& array);
T& operator [](const size_t& index) noexcept { assert(size_ > 0); return buffer_[index]; }
const T& operator[](const size_t& index) const noexcept { assert(size_ > 0); return buffer_[index]; }
void Reserve(const size_t& size);
void Resize(const size_t& size);
void Clear();
void PushBack(const T& element);
bool Erase(const size_t& index);
bool EraseSwapBack(const size_t& index);
int32_t IndexOf(const T& element) const;
bool Contains(const T& element) const;
size_t Size() const noexcept { return size_; }
size_t Capacity() const noexcept { return capacity_; }
private:
void TryGrow();
void AllocateElements(const size_t& count);
void AllocateElements(const size_t& count, const T& default_value);
void ReallocateAndConstructElements(const size_t& count);
void ReallocateElements(const size_t& count);
void CopyFrom(const DynamicArray& other);
void MoveFrom(DynamicArray&& other);
void Destruct();
};
#include "detail/DynamicArray.inl"
| /// <introduction>
/// dynamic array
/// implemented by array
/// </introduction>
#pragma once
#include <stdint.h>
#include "TypeTraits.h"
VAR_0<VAR_1 VAR_2>
class VAR_3
{
private:
VAR_2* VAR_4;
size_t capacity_;
size_t VAR_5;
public:
FUNC_0() : FUNC_1(nullptr), FUNC_2(0), capacity_(0) {};
VAR_3(const size_t& capacity);
VAR_3(const size_t& capacity, const VAR_2& VAR_6);
VAR_3(const CLASS_1& other);
FUNC_0(VAR_3&& other);
~FUNC_0();
VAR_3& operator =(const CLASS_1& VAR_7);
VAR_3& operator =(VAR_3&& VAR_7);
VAR_2& operator [](const size_t& VAR_8) VAR_9 { FUNC_3(VAR_5 > 0); return VAR_4[VAR_8]; }
const CLASS_0& operator[](const size_t& VAR_8) const VAR_9 { FUNC_3(VAR_5 > 0); return VAR_4[VAR_8]; }
void Reserve(const size_t& size);
void FUNC_4(const size_t& size);
void Clear();
void PushBack(const CLASS_0& VAR_10);
bool Erase(const size_t& VAR_8);
bool EraseSwapBack(const size_t& VAR_8);
int32_t IndexOf(const CLASS_0& VAR_10) const;
bool Contains(const CLASS_0& VAR_10) const;
size_t Size() const CLASS_2 { return VAR_5; }
size_t Capacity() const CLASS_2 { return capacity_; }
private:
void FUNC_5();
void FUNC_6(const size_t& count);
void FUNC_6(const size_t& count, const CLASS_0& VAR_6);
void ReallocateAndConstructElements(const size_t& count);
void FUNC_7(const size_t& count);
void CopyFrom(const CLASS_1& other);
void MoveFrom(CLASS_1&& other);
void Destruct();
};
#include "detail/DynamicArray.inl"
| 0.423377 | {'VAR_0': 'template', 'VAR_1': 'typename', 'VAR_2': 'T', 'CLASS_0': 'T', 'VAR_3': 'DynamicArray', 'FUNC_0': 'DynamicArray', 'CLASS_1': 'DynamicArray', 'VAR_4': 'buffer_', 'FUNC_1': 'buffer_', 'VAR_5': 'size_', 'FUNC_2': 'size_', 'VAR_6': 'default_value', 'VAR_7': 'array', 'VAR_8': 'index', 'VAR_9': 'noexcept', 'CLASS_2': 'noexcept', 'FUNC_3': 'assert', 'FUNC_4': 'Resize', 'VAR_10': 'element', 'FUNC_5': 'TryGrow', 'FUNC_6': 'AllocateElements', 'FUNC_7': 'ReallocateElements'} |
/*
* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "stt_main.h"
#include "stt_setting_dbus.h"
static int g_waiting_time = 1500;
static DBusConnection* g_conn = NULL;
int stt_setting_dbus_open_connection()
{
if( NULL != g_conn ) {
SLOG(LOG_WARN, TAG_STTC, "already existed connection");
return 0;
}
DBusError err;
int ret;
/* initialise the error value */
dbus_error_init(&err);
/* connect to the DBUS system bus, and check for errors */
g_conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Dbus Connection Error (%s)\n", err.message);
dbus_error_free(&err);
}
if (NULL == g_conn) {
SLOG(LOG_ERROR, TAG_STTC, "fail to get dbus connection \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
}
int pid = getpid();
char service_name[64];
memset(service_name, 0, 64);
snprintf(service_name, 64, "%s%d", STT_SETTING_SERVICE_NAME, pid);
SLOG(LOG_DEBUG, TAG_STTC, "service name is %s\n", service_name);
/* register our name on the bus, and check for errors */
ret = dbus_bus_request_name(g_conn, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Name Error (%s)\n", err.message);
dbus_error_free(&err);
}
if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
SLOG(LOG_ERROR, TAG_STTC, "fail dbus_bus_request_name()\n");
return STT_SETTING_ERROR_OPERATION_FAILED;
}
return 0;
}
int stt_setting_dbus_close_connection()
{
DBusError err;
dbus_error_init(&err);
int pid = getpid();
char service_name[64];
memset(service_name, 0, 64);
snprintf(service_name, 64, "%s%d", STT_SETTING_SERVICE_NAME, pid);
dbus_bus_release_name(g_conn, service_name, &err);
dbus_connection_close(g_conn);
g_conn = NULL;
return 0;
}
int stt_setting_dbus_request_hello()
{
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_HELLO);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting hello : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting hello");
}
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg = NULL;
int result = 0;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 500, &err);
dbus_message_unref(msg);
if (NULL != result_msg) {
dbus_message_unref(result_msg);
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting hello");
result = 0;
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting hello : no response");
result = -1;
}
return result;
}
int stt_setting_dbus_request_initialize()
{
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_INITIALIZE);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting initialize : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting initialize");
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting initialize : result = %d", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting initialize : result = %d", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_finalilze(void)
{
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_FINALIZE);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting finalize : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting finalize");
}
int pid = getpid();
dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting finallize : result = %d", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting finallize : result = %d", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_engine_list(stt_setting_supported_engine_cb callback, void* user_data)
{
if (NULL == callback) {
SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
return -1;
}
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_ENGINE_LIST);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get engine list : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting get engine list");
}
int pid = getpid();
dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
DBusMessageIter args;
if (dbus_message_iter_init(result_msg, &args)) {
/* Get result */
if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
dbus_message_iter_get_basic(&args, &result);
dbus_message_iter_next(&args);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting get engine list : result = %d \n", result);
int size ;
char* temp_id;
char* temp_name;
char* temp_path;
/* Get engine count */
if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
dbus_message_iter_get_basic(&args, &size);
dbus_message_iter_next(&args);
}
int i=0;
for (i=0 ; i<size ; i++) {
dbus_message_iter_get_basic(&args, &(temp_id));
dbus_message_iter_next(&args);
dbus_message_iter_get_basic(&args, &(temp_name));
dbus_message_iter_next(&args);
dbus_message_iter_get_basic(&args, &(temp_path));
dbus_message_iter_next(&args);
if (true != callback(temp_id, temp_name, temp_path, user_data)) {
break;
}
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine list : result = %d \n", result);
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine list : invalid message \n");
}
dbus_message_unref(result_msg);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine list : result message is NULL!! \n");
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_engine(char** engine_id)
{
if (NULL == engine_id) {
SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_ENGINE);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get engine : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting get engine ");
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
char* temp;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_STRING, &temp, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
*engine_id = strdup(temp);
if (NULL == *engine_id) {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine : Out of memory \n");
result = STT_SETTING_ERROR_OUT_OF_MEMORY;
} else {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting get engine : result(%d), engine id(%s)\n", result, *engine_id);
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine : result(%d) \n", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_set_engine(const char* engine_id)
{
if (NULL == engine_id) {
SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_SET_ENGINE);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set engine : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting set engine : engine id(%s)", engine_id);
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_STRING, &engine_id,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting set engine : result(%d) \n", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set engine : result(%d) \n", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_language_list(stt_setting_supported_language_cb callback, void* user_data)
{
if (NULL == callback) {
SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_LANG_LIST);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get language list : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting get language list");
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
DBusMessageIter args;
if (dbus_message_iter_init(result_msg, &args)) {
/* Get result */
if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
dbus_message_iter_get_basic(&args, &result);
dbus_message_iter_next(&args);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting get language list : result = %d \n", result);
int size = 0;
char* temp_id = NULL;
char* temp_lang = NULL;
/* Get engine id */
dbus_message_iter_get_basic(&args, &temp_id);
dbus_message_iter_next(&args);
if (NULL != temp_id) {
/* Get language count */
if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
dbus_message_iter_get_basic(&args, &size);
dbus_message_iter_next(&args);
}
int i=0;
for (i=0 ; i<size ; i++) {
dbus_message_iter_get_basic(&args, &(temp_lang) );
dbus_message_iter_next(&args);
if (true != callback(temp_id, temp_lang, user_data)) {
break;
}
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "Engine ID is NULL \n");
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get language list : result = %d \n", result);
}
}
dbus_message_unref(result_msg);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get language list : Result message is NULL!!");
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_default_language(char** language)
{
if (NULL == language) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_DEFAULT_LANG);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get default language : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting get default language");
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
char* temp_char;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBUS_TYPE_INT32, &result,
DBUS_TYPE_STRING, &temp_char,
DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
*language = strdup(temp_char);
if (NULL == *language) {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get default language : Out of memory \n");
result = STT_SETTING_ERROR_OUT_OF_MEMORY;
} else {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting get default language : result(%d), lang(%s)\n", result, *language);
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get default language : result(%d) \n", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_set_default_language(const char* language)
{
if (NULL == language) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_SET_DEFAULT_LANG);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set default language : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting set default language : lang(%s)\n", language);
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_STRING, &language,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBUS_TYPE_INT32, &result,
DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting set default language : result(%d)", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set default language : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_engine_setting(stt_setting_engine_setting_cb callback, void* user_data)
{
if (NULL == callback) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_ENGINE_SETTING);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get engine setting : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting get engine setting");
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
DBusMessageIter args;
if (dbus_message_iter_init(result_msg, &args)) {
/* Get result */
if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
dbus_message_iter_get_basic(&args, &result);
dbus_message_iter_next(&args);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< get engine setting : result = %d \n", result);
int size;
char* temp_id = NULL;
char* temp_key;
char* temp_value;
/* Get engine id */
dbus_message_iter_get_basic(&args, &temp_id);
dbus_message_iter_next(&args);
if (NULL != temp_id) {
/* Get setting count */
if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
dbus_message_iter_get_basic(&args, &size);
dbus_message_iter_next(&args);
}
int i=0;
for (i=0 ; i<size ; i++) {
dbus_message_iter_get_basic(&args, &(temp_key) );
dbus_message_iter_next(&args);
dbus_message_iter_get_basic(&args, &(temp_value) );
dbus_message_iter_next(&args);
if (true != callback(temp_id, temp_key, temp_value, user_data)) {
break;
}
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< get engine setting : result message is invalid \n");
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< get engine setting : result message is invalid \n");
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< get engine setting : Result message is NULL!! \n");
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_set_engine_setting(const char* key, const char* value)
{
if (NULL == key || NULL == value) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_SET_ENGINE_SETTING);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set engine setting : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting set engine setting : key(%s), value(%s)", key, value);
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_STRING, &key,
DBUS_TYPE_STRING, &value,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = -1;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting set engine setting : result(%d)", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set engine setting : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_profanity_filter(bool* value)
{
if (NULL == value) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_PROFANITY);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set profanity filter : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting set profanity filter");
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting get profanity filter : result(%d), value(%s)", result, *value ? "true":"false");
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get profanity filter : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_set_profanity_filter(const bool value)
{
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_SET_PROFANITY);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set profanity filter : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting set profanity filter : value(%s)", value ? "true":"false");
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INT32, &value,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting set profanity filter : result(%d)", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set profanity filter : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_punctuation_override(bool* value)
{
if (NULL == value) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_PUNCTUATION);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get punctuation override : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting get punctuation override ");
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting get punctuation override : result(%d), value(%s)", result, *value ? "true":"false");
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get punctuation override : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_set_punctuation_override(const bool value )
{
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_SET_PUNCTUATION);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set punctuation override : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting set punctuation override : value(%s)", value ? "true":"false");
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INT32, &value,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting set punctuation override : result(%d)", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set punctuation override : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_silence_detection(bool* value)
{
if (NULL == value) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_SILENCE);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get silence detection : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting get silence detection : value(%s)", value ? "true":"false");
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INT32, &value,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL == result_msg) {
dbus_message_unref(msg);
return STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
SLOG(LOG_DEBUG, TAG_STTC, "Get Silence Detection : result(%d), value(%d) \n", result, *value);
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_set_silence_detection(const bool value)
{
DBusMessage* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_SET_SILENCE);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set silence detection : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, ">>>> Request setting set silence detection : value(%s)", value ? "true":"false");
}
int pid = getpid();
dbus_message_append_args( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INT32, &value,
DBUS_TYPE_INVALID);
DBusError err;
dbus_error_init(&err);
DBusMessage* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< setting set set silence detection : result(%d)", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set set silence detection : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
| /*
* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "stt_main.h"
#include "stt_setting_dbus.h"
static int g_waiting_time = 1500;
static DBusConnection* g_conn = NULL;
int stt_setting_dbus_open_connection()
{
if( NULL != g_conn ) {
SLOG(LOG_WARN, TAG_STTC, "already existed connection");
return 0;
}
DBusError err;
int ret;
/* initialise the error value */
FUNC_0(&err);
/* connect to the DBUS system bus, and check for errors */
g_conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Dbus Connection Error (%s)\n", err.message);
dbus_error_free(&err);
}
if (NULL == g_conn) {
SLOG(LOG_ERROR, TAG_STTC, "fail to get dbus connection \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
}
int pid = getpid();
char service_name[64];
memset(service_name, 0, 64);
snprintf(service_name, 64, "%s%d", STT_SETTING_SERVICE_NAME, pid);
SLOG(VAR_0, TAG_STTC, "service name is %s\n", service_name);
/* register our name on the bus, and check for errors */
ret = FUNC_1(g_conn, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Name Error (%s)\n", err.message);
dbus_error_free(&err);
}
if (VAR_1 != ret) {
SLOG(LOG_ERROR, TAG_STTC, "fail dbus_bus_request_name()\n");
return STT_SETTING_ERROR_OPERATION_FAILED;
}
return 0;
}
int stt_setting_dbus_close_connection()
{
DBusError err;
FUNC_0(&err);
int pid = getpid();
char service_name[64];
memset(service_name, 0, 64);
snprintf(service_name, 64, "%s%d", STT_SETTING_SERVICE_NAME, pid);
dbus_bus_release_name(g_conn, service_name, &err);
dbus_connection_close(g_conn);
g_conn = NULL;
return 0;
}
int stt_setting_dbus_request_hello()
{
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_HELLO);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting hello : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting hello");
}
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg = NULL;
int result = 0;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, 500, &err);
dbus_message_unref(msg);
if (NULL != result_msg) {
dbus_message_unref(result_msg);
SLOG(VAR_0, TAG_STTC, "<<<< setting hello");
result = 0;
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting hello : no response");
result = -1;
}
return result;
}
int stt_setting_dbus_request_initialize()
{
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_INITIALIZE);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting initialize : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting initialize");
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< setting initialize : result = %d", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting initialize : result = %d", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_finalilze(void)
{
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_FINALIZE);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting finalize : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting finalize");
}
int pid = getpid();
FUNC_2(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< setting finallize : result = %d", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting finallize : result = %d", result);
}
dbus_message_unref(msg);
return result;
}
int FUNC_3(stt_setting_supported_engine_cb callback, void* user_data)
{
if (NULL == callback) {
SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
return -1;
}
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_ENGINE_LIST);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get engine list : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting get engine list");
}
int pid = getpid();
FUNC_2(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
CLASS_1 args;
if (dbus_message_iter_init(result_msg, &args)) {
/* Get result */
if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
dbus_message_iter_get_basic(&args, &result);
dbus_message_iter_next(&args);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< setting get engine list : result = %d \n", result);
int VAR_2 ;
char* temp_id;
char* temp_name;
char* temp_path;
/* Get engine count */
if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
dbus_message_iter_get_basic(&args, &VAR_2);
dbus_message_iter_next(&args);
}
int i=0;
for (i=0 ; i<VAR_2 ; i++) {
dbus_message_iter_get_basic(&args, &(temp_id));
dbus_message_iter_next(&args);
dbus_message_iter_get_basic(&args, &(temp_name));
dbus_message_iter_next(&args);
dbus_message_iter_get_basic(&args, &(temp_path));
dbus_message_iter_next(&args);
if (true != callback(temp_id, temp_name, temp_path, user_data)) {
break;
}
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine list : result = %d \n", result);
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine list : invalid message \n");
}
dbus_message_unref(result_msg);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine list : result message is NULL!! \n");
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_engine(char** VAR_3)
{
if (NULL == VAR_3) {
SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
VAR_4);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get engine : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting get engine ");
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
char* temp;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_STRING, &temp, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
*VAR_3 = strdup(temp);
if (NULL == *VAR_3) {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine : Out of memory \n");
result = STT_SETTING_ERROR_OUT_OF_MEMORY;
} else {
SLOG(VAR_0, TAG_STTC, "<<<< setting get engine : result(%d), engine id(%s)\n", result, *VAR_3);
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get engine : result(%d) \n", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_set_engine(const char* VAR_3)
{
if (NULL == VAR_3) {
SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_SET_ENGINE);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set engine : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting set engine : engine id(%s)", VAR_3);
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_STRING, &VAR_3,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< setting set engine : result(%d) \n", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set engine : result(%d) \n", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_language_list(stt_setting_supported_language_cb callback, void* user_data)
{
if (NULL == callback) {
SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_LANG_LIST);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get language list : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting get language list");
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
CLASS_1 args;
if (dbus_message_iter_init(result_msg, &args)) {
/* Get result */
if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
dbus_message_iter_get_basic(&args, &result);
dbus_message_iter_next(&args);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< setting get language list : result = %d \n", result);
int VAR_2 = 0;
char* temp_id = NULL;
char* temp_lang = NULL;
/* Get engine id */
dbus_message_iter_get_basic(&args, &temp_id);
dbus_message_iter_next(&args);
if (NULL != temp_id) {
/* Get language count */
if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
dbus_message_iter_get_basic(&args, &VAR_2);
dbus_message_iter_next(&args);
}
int i=0;
for (i=0 ; i<VAR_2 ; i++) {
dbus_message_iter_get_basic(&args, &(temp_lang) );
dbus_message_iter_next(&args);
if (true != callback(temp_id, temp_lang, user_data)) {
break;
}
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "Engine ID is NULL \n");
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get language list : result = %d \n", result);
}
}
dbus_message_unref(result_msg);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get language list : Result message is NULL!!");
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_default_language(char** language)
{
if (NULL == language) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_DEFAULT_LANG);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get default language : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting get default language");
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
char* temp_char;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBUS_TYPE_INT32, &result,
DBUS_TYPE_STRING, &temp_char,
DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
*language = strdup(temp_char);
if (NULL == *language) {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get default language : Out of memory \n");
result = STT_SETTING_ERROR_OUT_OF_MEMORY;
} else {
SLOG(VAR_0, TAG_STTC, "<<<< setting get default language : result(%d), lang(%s)\n", result, *language);
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get default language : result(%d) \n", result);
}
dbus_message_unref(msg);
return result;
}
int FUNC_4(const char* language)
{
if (NULL == language) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_SET_DEFAULT_LANG);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set default language : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting set default language : lang(%s)\n", language);
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_STRING, &language,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err,
DBUS_TYPE_INT32, &result,
DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< setting set default language : result(%d)", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set default language : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_engine_setting(stt_setting_engine_setting_cb callback, void* user_data)
{
if (NULL == callback) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_ENGINE_SETTING);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get engine setting : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting get engine setting");
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
CLASS_1 args;
if (dbus_message_iter_init(result_msg, &args)) {
/* Get result */
if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
dbus_message_iter_get_basic(&args, &result);
dbus_message_iter_next(&args);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< get engine setting : result = %d \n", result);
int VAR_2;
char* temp_id = NULL;
char* temp_key;
char* temp_value;
/* Get engine id */
dbus_message_iter_get_basic(&args, &temp_id);
dbus_message_iter_next(&args);
if (NULL != temp_id) {
/* Get setting count */
if (DBUS_TYPE_INT32 == dbus_message_iter_get_arg_type(&args)) {
dbus_message_iter_get_basic(&args, &VAR_2);
dbus_message_iter_next(&args);
}
int i=0;
for (i=0 ; i<VAR_2 ; i++) {
dbus_message_iter_get_basic(&args, &(temp_key) );
dbus_message_iter_next(&args);
dbus_message_iter_get_basic(&args, &(temp_value) );
dbus_message_iter_next(&args);
if (true != callback(temp_id, temp_key, temp_value, user_data)) {
break;
}
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< get engine setting : result message is invalid \n");
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
}
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< get engine setting : result message is invalid \n");
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< get engine setting : Result message is NULL!! \n");
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_set_engine_setting(const char* key, const char* value)
{
if (NULL == key || NULL == value) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
VAR_5);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set engine setting : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting set engine setting : key(%s), value(%s)", key, value);
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_STRING, &key,
DBUS_TYPE_STRING, &value,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = -1;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< setting set engine setting : result(%d)", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set engine setting : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_profanity_filter(bool* value)
{
if (NULL == value) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
VAR_6);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set profanity filter : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting set profanity filter");
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< setting get profanity filter : result(%d), value(%s)", result, *value ? "true":"false");
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get profanity filter : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_set_profanity_filter(const bool value)
{
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_SET_PROFANITY);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set profanity filter : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting set profanity filter : value(%s)", value ? "true":"false");
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INT32, &value,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< setting set profanity filter : result(%d)", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set profanity filter : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_punctuation_override(bool* value)
{
if (NULL == value) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_PUNCTUATION);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get punctuation override : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting get punctuation override ");
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< setting get punctuation override : result(%d), value(%s)", result, *value ? "true":"false");
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting get punctuation override : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
int FUNC_5(const bool value )
{
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_SET_PUNCTUATION);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set punctuation override : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting set punctuation override : value(%s)", value ? "true":"false");
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INT32, &value,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< setting set punctuation override : result(%d)", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set punctuation override : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_get_silence_detection(bool* value)
{
if (NULL == value) {
SLOG(LOG_ERROR, TAG_STTC, "Input Parameter is NULL");
return STT_SETTING_ERROR_INVALID_PARAMETER;
}
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_GET_SILENCE);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting get silence detection : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting get silence detection : value(%s)", value ? "true":"false");
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INT32, &value,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL == result_msg) {
dbus_message_unref(msg);
return STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INT32, value, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
SLOG(VAR_0, TAG_STTC, "Get Silence Detection : result(%d), value(%d) \n", result, *value);
dbus_message_unref(msg);
return result;
}
int stt_setting_dbus_request_set_silence_detection(const bool value)
{
CLASS_0* msg;
msg = dbus_message_new_method_call(
STT_SERVER_SERVICE_NAME,
STT_SERVER_SERVICE_OBJECT_PATH,
STT_SERVER_SERVICE_INTERFACE,
STT_SETTING_METHOD_SET_SILENCE);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> Request setting set silence detection : Fail to make message \n");
return STT_SETTING_ERROR_OPERATION_FAILED;
} else {
SLOG(VAR_0, TAG_STTC, ">>>> Request setting set silence detection : value(%s)", value ? "true":"false");
}
int pid = getpid();
FUNC_2( msg,
DBUS_TYPE_INT32, &pid,
DBUS_TYPE_INT32, &value,
DBUS_TYPE_INVALID);
DBusError err;
FUNC_0(&err);
CLASS_0* result_msg;
int result = STT_SETTING_ERROR_OPERATION_FAILED;
result_msg = dbus_connection_send_with_reply_and_block(g_conn, msg, g_waiting_time, &err);
if (NULL != result_msg) {
dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Get arguments error (%s)\n", err.message);
dbus_error_free(&err);
result = STT_SETTING_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
}
if (0 == result) {
SLOG(VAR_0, TAG_STTC, "<<<< setting set set silence detection : result(%d)", result);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< setting set set silence detection : result(%d)", result);
}
dbus_message_unref(msg);
return result;
}
| 0.152933 | {'FUNC_0': 'dbus_error_init', 'VAR_0': 'LOG_DEBUG', 'FUNC_1': 'dbus_bus_request_name', 'VAR_1': 'DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER', 'CLASS_0': 'DBusMessage', 'FUNC_2': 'dbus_message_append_args', 'FUNC_3': 'stt_setting_dbus_request_get_engine_list', 'CLASS_1': 'DBusMessageIter', 'VAR_2': 'size', 'VAR_3': 'engine_id', 'VAR_4': 'STT_SETTING_METHOD_GET_ENGINE', 'FUNC_4': 'stt_setting_dbus_request_set_default_language', 'VAR_5': 'STT_SETTING_METHOD_SET_ENGINE_SETTING', 'VAR_6': 'STT_SETTING_METHOD_GET_PROFANITY', 'FUNC_5': 'stt_setting_dbus_request_set_punctuation_override'} |
#ifndef WORLD_H
#define WORLD_H
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <QPainter>
#include <QPoint>
#include "vect.h"
#include "physics.h"
#include "nn.h"
class World {
public:
static const int max_cell_size = 16; // maximum stable cell radius for physics engine
double scale = 1;
Vect mousePosition, clickPos;
Cell *selectedCell = nullptr;
Vect cameraPosition;
int xsize = 800,
ysize = 1000;
Physics physics = Physics(xsize, ysize);
vector<pair<float, NN>> population;
World();
void prepareGraph(Physics &physics);
vector<float> calculateMark(Cell &cell);
void update();
void draw(QPainter &painter);
void growPlant(Physics &physics, NN &nn);
void optimizeJoints(Physics &physics);
void mousePress(int x, int y);
void mouseMove(int x, int y);
void mouseRelease(int x, int y);
void keyPress(int key);
void wheel(double delta);
void draw(Cell &cell, QPainter &painter);
void draw(Joint &joint, QPainter &painter);
};
#endif // WORLD_H
| #ifndef WORLD_H
#define WORLD_H
#include <iostream>
#include <IMPORT_0>
#include <unordered_map>
#include <QPainter>
#include <QPoint>
#include "vect.h"
#include "physics.h"
#include "nn.h"
class World {
public:
static const int max_cell_size = 16; // maximum stable cell radius for physics engine
double scale = 1;
Vect mousePosition, clickPos;
Cell *selectedCell = nullptr;
Vect cameraPosition;
int xsize = 800,
ysize = 1000;
CLASS_0 physics = FUNC_0(xsize, ysize);
vector<pair<float, NN>> VAR_0;
World();
void prepareGraph(CLASS_0 &physics);
vector<float> calculateMark(Cell &cell);
void update();
void draw(QPainter &painter);
void growPlant(CLASS_0 &physics, NN &VAR_1);
void optimizeJoints(CLASS_0 &physics);
void mousePress(int x, int y);
void FUNC_1(int x, int y);
void mouseRelease(int x, int y);
void FUNC_2(int VAR_2);
void wheel(double delta);
void draw(Cell &cell, QPainter &painter);
void draw(Joint &joint, QPainter &painter);
};
#endif // WORLD_H
| 0.087609 | {'IMPORT_0': 'unordered_set', 'CLASS_0': 'Physics', 'FUNC_0': 'Physics', 'VAR_0': 'population', 'VAR_1': 'nn', 'FUNC_1': 'mouseMove', 'FUNC_2': 'keyPress', 'VAR_2': 'key'} |
#ifndef IHTTPCLIENT_H
#define IHTTPCLIENT_H
#include <QObject>
#include <QHash>
#include "ipostpreparestrategyfactory.h"
struct ContentData
{
QString DataString;
QByteArray DataRaw;
QString ContentType;
QString FileName;
};
struct PostOptions
{
QString PrepareStrategy;
PostOptions();
};
class IPostPrepareStrategyFactory;
class IHttpClient : public QObject
{
Q_OBJECT
public:
explicit IHttpClient(QObject *parent = 0);
virtual void Get(const QString &url) = 0;
virtual void Download(const QString &url, const QString &file) = 0;
virtual void Post(const QString &url, const QHash<QString,QString> & params, const PostOptions & Options = PostOptions()) = 0;
virtual void Post(const QString &url, const QHash<QString,ContentData> & params, const PostOptions & Options = PostOptions()) = 0;
virtual bool WasError() = 0;
virtual QString GetErrorString() = 0;
virtual QString GetContent() = 0;
virtual QByteArray GetPageData() = 0;
virtual QString GetBase64() = 0;
virtual int GetStatus() = 0;
virtual QString GetLastUrl() = 0;
virtual void Connect(QObject *object, const char * slot) = 0;
virtual void Disconnect() = 0;
virtual void Stop() = 0;
virtual QString GetHeader(const QString& header) = 0;
virtual void AddHeader(const QString& name,const QString& value) = 0;
virtual void CleanHeader() = 0;
virtual void SetProxy(const QString& server, int Port, bool IsHttp, const QString& name, const QString& password) = 0;
virtual QString GetCookiesForUrl(const QString& url) = 0;
virtual void SetPostPrepareStrategyFactory(IPostPrepareStrategyFactory* PostPrepareStrategyFactory) = 0;
virtual QString SaveCookies() = 0;
virtual void RestoreCookies(const QString& cookies) = 0;
signals:
void Finished();
void DownloadProgress(qint64 BytesReceived, qint64 BytesTotal);
public slots:
};
#endif // IHTTPCLIENT_H
| #ifndef IHTTPCLIENT_H
#define IHTTPCLIENT_H
#include <QObject>
#include <QHash>
#include "ipostpreparestrategyfactory.h"
struct ContentData
{
QString DataString;
QByteArray DataRaw;
QString VAR_0;
QString FileName;
};
struct PostOptions
{
QString PrepareStrategy;
PostOptions();
};
class IPostPrepareStrategyFactory;
class IHttpClient : public QObject
{
Q_OBJECT
public:
explicit IHttpClient(QObject *parent = 0);
CLASS_0 void Get(const QString &url) = 0;
CLASS_0 void FUNC_0(const QString &url, const QString &file) = 0;
CLASS_0 void Post(const QString &url, const QHash<QString,QString> & params, const PostOptions & Options = PostOptions()) = 0;
CLASS_0 void Post(const QString &url, const QHash<QString,ContentData> & params, const PostOptions & Options = PostOptions()) = 0;
CLASS_0 bool WasError() = 0;
CLASS_0 QString GetErrorString() = 0;
CLASS_0 QString GetContent() = 0;
CLASS_0 QByteArray GetPageData() = 0;
CLASS_0 QString GetBase64() = 0;
CLASS_0 int GetStatus() = 0;
CLASS_0 QString GetLastUrl() = 0;
CLASS_0 void Connect(QObject *object, const char * slot) = 0;
CLASS_0 void Disconnect() = 0;
CLASS_0 void Stop() = 0;
CLASS_0 QString GetHeader(const QString& header) = 0;
CLASS_0 void AddHeader(const QString& name,const QString& value) = 0;
CLASS_0 void CleanHeader() = 0;
CLASS_0 void FUNC_1(const QString& server, int Port, bool IsHttp, const QString& name, const QString& password) = 0;
CLASS_0 QString FUNC_2(const QString& url) = 0;
CLASS_0 void SetPostPrepareStrategyFactory(IPostPrepareStrategyFactory* PostPrepareStrategyFactory) = 0;
CLASS_0 QString SaveCookies() = 0;
CLASS_0 void RestoreCookies(const QString& VAR_1) = 0;
signals:
void Finished();
void DownloadProgress(qint64 BytesReceived, qint64 BytesTotal);
public VAR_2:
};
#endif // IHTTPCLIENT_H
| 0.135138 | {'VAR_0': 'ContentType', 'CLASS_0': 'virtual', 'FUNC_0': 'Download', 'FUNC_1': 'SetProxy', 'FUNC_2': 'GetCookiesForUrl', 'VAR_1': 'cookies', 'VAR_2': 'slots'} |
/**
* Free an allocated data
* @param data pointer to an allocated memory
*/
void dm_free(const void * data)
{
if(data == &zero_mem) return;
if(data == NULL) return;
dm_ent_t * e = (dm_ent_t *)((uint8_t *) data - sizeof(dm_header_t));
e->header.used = 0;
#if DM_CUSTOM == 0
dm_ent_t * e_next;
e_next = ent_get_next(e);
while(e_next != NULL) {
if(e_next->header.used == 0) {
e->header.d_size += e_next->header.d_size + sizeof(e->header);
} else {
break;
}
e_next = ent_get_next(e_next);
}
#else
DM_CUST_FREE(e);
#endif
} | /**
* Free an allocated data
* @param data pointer to an allocated memory
*/
void dm_free(const void * VAR_0)
{
if(VAR_0 == &VAR_1) return;
if(VAR_0 == NULL) return;
dm_ent_t * VAR_2 = (dm_ent_t *)((uint8_t *) VAR_0 - sizeof(dm_header_t));
VAR_2->VAR_3.VAR_4 = 0;
#if DM_CUSTOM == 0
dm_ent_t * VAR_5;
VAR_5 = FUNC_0(VAR_2);
while(VAR_5 != NULL) {
if(VAR_5->VAR_3.VAR_4 == 0) {
VAR_2->VAR_3.VAR_6 += VAR_5->VAR_3.VAR_6 + sizeof(VAR_2->VAR_3);
} else {
break;
}
VAR_5 = FUNC_0(VAR_5);
}
#else
FUNC_1(VAR_2);
#endif
} | 0.813721 | {'VAR_0': 'data', 'VAR_1': 'zero_mem', 'VAR_2': 'e', 'VAR_3': 'header', 'VAR_4': 'used', 'VAR_5': 'e_next', 'FUNC_0': 'ent_get_next', 'VAR_6': 'd_size', 'FUNC_1': 'DM_CUST_FREE'} |
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| <EMAIL> so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef __PDO_MYSQL_H__
#define __PDO_MYSQL_H__
#include <runtime/ext/pdo_driver.h>
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
enum {
PDO_MYSQL_ATTR_USE_BUFFERED_QUERY = PDO_ATTR_DRIVER_SPECIFIC,
PDO_MYSQL_ATTR_LOCAL_INFILE,
PDO_MYSQL_ATTR_INIT_COMMAND,
PDO_MYSQL_ATTR_READ_DEFAULT_FILE,
PDO_MYSQL_ATTR_READ_DEFAULT_GROUP,
PDO_MYSQL_ATTR_MAX_BUFFER_SIZE,
PDO_MYSQL_ATTR_COMPRESS,
PDO_MYSQL_ATTR_DIRECT_QUERY,
PDO_MYSQL_ATTR_FOUND_ROWS,
PDO_MYSQL_ATTR_IGNORE_SPACE
};
///////////////////////////////////////////////////////////////////////////////
class PDOMySql : public PDODriver {
public:
PDOMySql();
virtual PDOConnection *createConnectionObject();
};
///////////////////////////////////////////////////////////////////////////////
}
#endif // __PDO_MYSQL_H__
| /*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| <EMAIL> so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef __PDO_MYSQL_H__
#define __PDO_MYSQL_H__
#include <runtime/ext/pdo_driver.h>
CLASS_0 HPHP {
///////////////////////////////////////////////////////////////////////////////
enum {
PDO_MYSQL_ATTR_USE_BUFFERED_QUERY = PDO_ATTR_DRIVER_SPECIFIC,
PDO_MYSQL_ATTR_LOCAL_INFILE,
PDO_MYSQL_ATTR_INIT_COMMAND,
PDO_MYSQL_ATTR_READ_DEFAULT_FILE,
PDO_MYSQL_ATTR_READ_DEFAULT_GROUP,
VAR_0,
PDO_MYSQL_ATTR_COMPRESS,
PDO_MYSQL_ATTR_DIRECT_QUERY,
PDO_MYSQL_ATTR_FOUND_ROWS,
PDO_MYSQL_ATTR_IGNORE_SPACE
};
///////////////////////////////////////////////////////////////////////////////
class VAR_1 : public PDODriver {
public:
FUNC_0();
virtual PDOConnection *createConnectionObject();
};
///////////////////////////////////////////////////////////////////////////////
}
#endif // __PDO_MYSQL_H__
| 0.238297 | {'CLASS_0': 'namespace', 'VAR_0': 'PDO_MYSQL_ATTR_MAX_BUFFER_SIZE', 'VAR_1': 'PDOMySql', 'FUNC_0': 'PDOMySql'} |
#include <string.h>
#include <stdlib.h>
//AST Includes
#include "ast/ast.h"
#include "ast/util/str_ast.h"
#include "ast/util/equals_ast.h"
//Typeinference Includes
#include "transpiler/main/typeinference/typeinfer.h"
//Typechecker Includes
#include "_tc.h"
#include "typechecker/util/tc_errors.h"
#include "typechecker/util/tc_utils.h"
#include "typecheck.h"
#include "tcctx.h"
void tc_stmt(struct Stmt* s, struct TCCtx* tcctx){
tcctx->current_line_num = s->super.line_num;
switch(s->kind){
case 0: tc_loopstmt(s->ptr.m0, tcctx); break;
case 1: tc_methodcall(s->ptr.m1, tcctx); break;
case 2: tc_whilestmt(s->ptr.m2, tcctx); break;
case 3: tc_ifstmt(s->ptr.m3, tcctx); break;
case 4: tc_retstmt(s->ptr.m4, tcctx); break;
case 5: tc_assignstmt(s->ptr.m5, tcctx); break;
case 6: tc_trycatchstmt(s->ptr.m6, tcctx); break;
case 7: tc_forstmt(s->ptr.m7, tcctx); break;
case 8: tc_switchstmt(s->ptr.m8, tcctx); break;
case 99:
if(s->is_continue){ }
if(s->is_break) { }
if(s->is_throw) { tc_throwstmt(s, tcctx); }
}
}
void tc_throwstmt(struct Stmt* s, struct TCCtx* tcctx){
struct Method* m = tcctx->current_fn;
if(m->decl->throws) { return; }
//are we inside try-catch stmt?
if(tcctx->depth_inside_try_stmt > 0){ return; }
char* s1 = str_stmt(s);
char msg[100];
sprintf(msg, "\t%s\n", s1);
strcat(msg, ERR_NO_THROW_OUTSIDE_TRY_OR_THROWS_SUBR);
free(s1);
error(tcctx, msg);
}
void tc_ifstmt(struct IfStmt* i, struct TCCtx* tcctx){
tcctx->current_line_num = i->super.line_num;
struct Type* type =
infer_type_expr(tcctx->current_filename, tcctx->st, i->condition);
if(!is_bool_type(type)){
char* s1 = str_expr(i->condition);
char msg[100];
sprintf(msg, "\t%s\n", s1);
strcat(msg, ERR_CONDITION_REQUIRES_BOOL);
free(s1);
error(tcctx, msg);
}
tc_stmtblock(i->block, tcctx);
}
void tc_whilestmt(struct WhileStmt* w, struct TCCtx* tcctx){
tcctx->current_line_num = w->super.line_num;
struct Type* type = infer_type_expr(tcctx->current_filename, tcctx->st, w->condition);
if(!is_bool_type(type)){
char* s1 = str_expr(w->condition);
char msg[200];
sprintf(msg, "\t%s\n", s1);
strcat(msg, ERR_CONDITION_REQUIRES_BOOL);
free(s1);
error(tcctx, msg);
}
tcctx->depth_inside_loop++;
tc_stmtblock(w->block, tcctx);
tcctx->depth_inside_loop--;
}
void tc_loopstmt(struct LoopStmt* l, struct TCCtx* tcctx){
tcctx->current_line_num = l->super.line_num;
struct Type* type = infer_type_expr(tcctx->current_filename, tcctx->st, l->count);
if(!is_integer_type(type)){
char* s1 = str_expr(l->count);
char msg[200];
sprintf(msg, "\tloop %s\n", s1);
strcat(msg, ERR_LOOP_REQUIRES_INT);
free(s1);
error(tcctx, msg);
}
tcctx->depth_inside_loop++;
tc_stmtblock(l->block, tcctx);
tcctx->depth_inside_loop--;
}
void tc_retstmt(struct RetStmt* r, struct TCCtx* tcctx){
tcctx->current_line_num = r->super.line_num;
struct Type* returnType = tcctx->current_fn->decl->return_type;
struct Type* returnedType =
infer_type_expr(tcctx->current_filename, tcctx->st, r->return_value);
tc_expr(r->return_value, tcctx);
if(is_integer_type(returnType)
&& is_integer_type(returnedType))
{ return; }
//do not check if returned expr
//is a call to malloc
if(is_malloc(r->return_value)){ return; }
if(!eq_type(returnType, returnedType)){
char* s1 = str_type(returnType);
char* s2 = str_type(returnedType);
char* s3 = str_ret_stmt(r);
char msg[200];
sprintf(msg, "\t%s\nexpected type: %s, actual type: %s\n", s3, s1, s2);
strcat(msg, ERR_RETURN_TYPE_MISMATCH);
free(s1);
free(s2);
free(s3);
error(tcctx, msg);
}
}
void tc_switchstmt(struct SwitchStmt* s, struct TCCtx* tcctx){
tcctx->current_line_num = s->super.line_num;
struct Type* type =
infer_type_expr(tcctx->current_filename, tcctx->st, s->expr);
if(!is_primitive_type(type)){
char* s1 = str_expr(s->expr);
char msg[200];
sprintf(msg, "\tswitch %s\n", s1);
strcat(msg, ERR_SWITCH_REQUIRES_PRIMITIVE_TYPE);
free(s1);
error(tcctx, msg);
}
for(uint32_t i = 0; i < s->count_cases; i++){
struct CaseStmt* c = s->cases[i];
const bool isBool = c->const_value->kind == 1;
const bool isInt = c->const_value->kind == 2;
const bool isChar = c->const_value->kind == 3;
bool isErr = false;
if(isBool && !is_bool_type(type)){ isErr = true; }
if(isChar && !is_char_type(type)){ isErr = true; }
if(isInt && !is_integer_type(type)){ isErr = true; }
if(isErr){
char* s1 = str_case_stmt(c);
char msg[200];
sprintf(msg, "\t%s\n", s1);
strcat(msg, ERR_CASE_TYPE_MISMATCH);
free(s1);
error(tcctx, msg);
}
}
}
void tc_forstmt(struct ForStmt* f, struct TCCtx* tcctx){
tcctx->current_line_num = f->super.line_num;
tc_range(f->range, tcctx);
tcctx->depth_inside_loop++;
tc_stmtblock(f->block, tcctx);
tcctx->depth_inside_loop--;
}
void tc_trycatchstmt(struct TryCatchStmt* tcs, struct TCCtx* tcctx){
tcctx->current_line_num = tcs->super.line_num;
tcctx->depth_inside_try_stmt++;
tc_stmtblock(tcs->try_block, tcctx);
tcctx->depth_inside_try_stmt--;
tc_stmtblock(tcs->catch_block, tcctx);
}
| #include <string.h>
#include <stdlib.h>
//AST Includes
#include "ast/ast.h"
#include "ast/util/str_ast.h"
#include "ast/util/equals_ast.h"
//Typeinference Includes
#include "transpiler/main/typeinference/typeinfer.h"
//Typechecker Includes
#include "IMPORT_0"
#include "typechecker/util/tc_errors.h"
#include "typechecker/util/tc_utils.h"
#include "typecheck.h"
#include "tcctx.h"
void tc_stmt(struct Stmt* s, struct TCCtx* tcctx){
tcctx->current_line_num = s->super.line_num;
switch(s->kind){
case 0: tc_loopstmt(s->ptr.m0, tcctx); break;
case 1: tc_methodcall(s->ptr.VAR_0, tcctx); break;
case 2: tc_whilestmt(s->ptr.m2, tcctx); break;
case 3: tc_ifstmt(s->ptr.m3, tcctx); break;
case 4: tc_retstmt(s->ptr.m4, tcctx); break;
case 5: tc_assignstmt(s->ptr.m5, tcctx); break;
case 6: tc_trycatchstmt(s->ptr.m6, tcctx); break;
case 7: tc_forstmt(s->ptr.m7, tcctx); break;
case 8: tc_switchstmt(s->ptr.m8, tcctx); break;
case 99:
if(s->is_continue){ }
if(s->is_break) { }
if(s->is_throw) { tc_throwstmt(s, tcctx); }
}
}
void tc_throwstmt(struct Stmt* s, struct TCCtx* tcctx){
struct Method* m = tcctx->current_fn;
if(m->decl->throws) { return; }
//are we inside try-catch stmt?
if(tcctx->depth_inside_try_stmt > 0){ return; }
char* s1 = str_stmt(s);
char VAR_1[100];
sprintf(VAR_1, "\t%s\n", s1);
strcat(VAR_1, ERR_NO_THROW_OUTSIDE_TRY_OR_THROWS_SUBR);
FUNC_0(s1);
error(tcctx, VAR_1);
}
void tc_ifstmt(struct IfStmt* i, struct TCCtx* tcctx){
tcctx->current_line_num = i->super.line_num;
struct Type* type =
infer_type_expr(tcctx->current_filename, tcctx->st, i->condition);
if(!is_bool_type(type)){
char* s1 = str_expr(i->condition);
char VAR_1[100];
sprintf(VAR_1, "\t%s\n", s1);
strcat(VAR_1, ERR_CONDITION_REQUIRES_BOOL);
FUNC_0(s1);
error(tcctx, VAR_1);
}
FUNC_1(i->block, tcctx);
}
void tc_whilestmt(struct WhileStmt* w, struct TCCtx* tcctx){
tcctx->current_line_num = w->super.line_num;
struct Type* type = infer_type_expr(tcctx->current_filename, tcctx->st, w->condition);
if(!is_bool_type(type)){
char* s1 = str_expr(w->condition);
char VAR_1[200];
sprintf(VAR_1, "\t%s\n", s1);
strcat(VAR_1, ERR_CONDITION_REQUIRES_BOOL);
FUNC_0(s1);
error(tcctx, VAR_1);
}
tcctx->depth_inside_loop++;
FUNC_1(w->block, tcctx);
tcctx->depth_inside_loop--;
}
void tc_loopstmt(struct LoopStmt* l, struct TCCtx* tcctx){
tcctx->current_line_num = l->super.line_num;
struct Type* type = infer_type_expr(tcctx->current_filename, tcctx->st, l->count);
if(!is_integer_type(type)){
char* s1 = str_expr(l->count);
char VAR_1[200];
sprintf(VAR_1, "\tloop %s\n", s1);
strcat(VAR_1, ERR_LOOP_REQUIRES_INT);
FUNC_0(s1);
error(tcctx, VAR_1);
}
tcctx->depth_inside_loop++;
FUNC_1(l->block, tcctx);
tcctx->depth_inside_loop--;
}
void tc_retstmt(struct RetStmt* r, struct TCCtx* tcctx){
tcctx->current_line_num = r->super.line_num;
struct Type* returnType = tcctx->current_fn->decl->return_type;
struct Type* returnedType =
infer_type_expr(tcctx->current_filename, tcctx->st, r->return_value);
tc_expr(r->return_value, tcctx);
if(is_integer_type(returnType)
&& is_integer_type(returnedType))
{ return; }
//do not check if returned expr
//is a call to malloc
if(is_malloc(r->return_value)){ return; }
if(!eq_type(returnType, returnedType)){
char* s1 = str_type(returnType);
char* s2 = str_type(returnedType);
char* s3 = str_ret_stmt(r);
char VAR_1[200];
sprintf(VAR_1, "\t%s\nexpected type: %s, actual type: %s\n", s3, s1, s2);
strcat(VAR_1, ERR_RETURN_TYPE_MISMATCH);
FUNC_0(s1);
FUNC_0(s2);
FUNC_0(s3);
error(tcctx, VAR_1);
}
}
void tc_switchstmt(struct CLASS_0* s, struct TCCtx* tcctx){
tcctx->current_line_num = s->super.line_num;
struct Type* type =
infer_type_expr(tcctx->current_filename, tcctx->st, s->expr);
if(!is_primitive_type(type)){
char* s1 = str_expr(s->expr);
char VAR_1[200];
sprintf(VAR_1, "\tswitch %s\n", s1);
strcat(VAR_1, ERR_SWITCH_REQUIRES_PRIMITIVE_TYPE);
FUNC_0(s1);
error(tcctx, VAR_1);
}
for(uint32_t i = 0; i < s->count_cases; i++){
struct CaseStmt* c = s->cases[i];
const bool isBool = c->const_value->kind == 1;
const bool isInt = c->const_value->kind == 2;
const bool isChar = c->const_value->kind == 3;
bool isErr = false;
if(isBool && !is_bool_type(type)){ isErr = true; }
if(isChar && !is_char_type(type)){ isErr = true; }
if(isInt && !is_integer_type(type)){ isErr = true; }
if(isErr){
char* s1 = str_case_stmt(c);
char VAR_1[200];
sprintf(VAR_1, "\t%s\n", s1);
strcat(VAR_1, ERR_CASE_TYPE_MISMATCH);
FUNC_0(s1);
error(tcctx, VAR_1);
}
}
}
void tc_forstmt(struct ForStmt* f, struct TCCtx* tcctx){
tcctx->current_line_num = f->super.line_num;
FUNC_2(f->range, tcctx);
tcctx->depth_inside_loop++;
FUNC_1(f->block, tcctx);
tcctx->depth_inside_loop--;
}
void tc_trycatchstmt(struct CLASS_1* tcs, struct TCCtx* tcctx){
tcctx->current_line_num = tcs->super.line_num;
tcctx->depth_inside_try_stmt++;
FUNC_1(tcs->try_block, tcctx);
tcctx->depth_inside_try_stmt--;
FUNC_1(tcs->catch_block, tcctx);
}
| 0.07741 | {'IMPORT_0': '_tc.h', 'VAR_0': 'm1', 'VAR_1': 'msg', 'FUNC_0': 'free', 'FUNC_1': 'tc_stmtblock', 'CLASS_0': 'SwitchStmt', 'FUNC_2': 'tc_range', 'CLASS_1': 'TryCatchStmt'} |
#include "cambadge.h"
#include "globals.h"
// serial control - mostly a remnant from the old serial camera board, some parts may not entirely work.
// useful for messing with camera & OLED commands etc. as well as getting live image data
// for image data you will probably want to crank up the baudrate to 2Mbaud or higher
#if serialcontrol==1
unsigned int camoptions;
void polluart(void) { // check for serial commands. Slightly crude but simple
unsigned int i, pchange, x, y, outptr;
unsigned char c;
if (tick) {
if (rxptr) if (++rxtimer > 2) rxptr = 0; // serial receive timeout
if (U2STAbits.OERR) {
U2STAbits.OERR = 0;
rxptr = 0;
} // UART overrun
if (U2STAbits.FERR) {
U2STAbits.FERR = 0;
rxptr = 0;
} // Framing error
}
if (rxptr == 0) return;
switch (rxbuf[0]) {
case 0x10:// 0x10 <adr> <value> set camera register. returns 0x55
if (rxptr != 3) break;
rxptr = 0;
cam_setreg(rxbuf[1], rxbuf[2]);
u2txbyte(0x55);
break;
case 0x11: // 0x11 <rr> read camera register. returns 1 byte register value
if (rxptr != 2) break;
rxptr = 0;
u2txbyte(readcamreg(rxbuf[1]));
break;
case 0x13: // 0x12 <en> <graben> camera enable/disable
if (rxptr != 3) break;
rxptr=0;
cam_enable(rxbuf[1]);
cam_grabenable(rxbuf[2],0,0);
u2txbyte(0x55);
break;
case 0x14: // 14 xstart/2 ystart/2 xdiv ydiv refclkdiv set capture parameters 0 = unchanged
if (rxptr != 6) break;
rxptr = 0;
if (rxbuf[1]) xstart = (unsigned int) rxbuf[1]*2;
if (rxbuf[2])ystart = (unsigned int) rxbuf[2]*2;
if (rxbuf[3])xdiv = (unsigned int) rxbuf[3];
if (rxbuf[4])ydiv = (unsigned int) rxbuf[4];
if (rxbuf[5]) REFOCON = 0b1001001000000000 | ((unsigned int) rxbuf[5]) << 16; // XCLK clock to cam
u2txbyte(0x55);
break;
case 0x15 : // 15 poll camera state
if(rxptr!=1) break;
rxptr=0;
u2txbyte(cam_newframe?1:0 | cam_busy?2:0 | cam_wrap?4:0 | cam_started?8:0);
u2txword(linecnt);
u2txword(camaddr);
break;
case 0x16 : // 16 xx return image. xx=1 to wait for new frame
// could be optimised by starting to send while capture in progress
if(rxptr!=2) break;
rxptr=0;
if(rxbuf[1]) while(!cam_newframe);
for(x=1,i=0;i!=xpixels*ypixels*(camflags & camopt_mono)?1:2;i++) {
kickwatchdog;
u2txbyte(cambuffer[x++]);
}
cam_newframe=0;
break;
case 0x20: // return info
if(rxptr!=1) break;
rxptr=0;
u2txbyte(versionbyte);
u2txbyte(clockfreq / 1000000);
u2txbyte(cambufsize >> 16);
u2txbyte(cambufsize >> 8);
u2txbyte(cambufsize & 0xff);
rxptr = 0;
break;
case 0x30: // 30 return accel data, bat level, bat state
if(rxptr!=1) break;
rxptr=0;
u2txword(accx);
u2txword(accy);
u2txword(accz);
u2txbyte(butstate);
u2txbyte(butpress);
u2txword(battlevel);
break;
}//switch
if (rxptr == 0) powerdowntimer = 0; // reset timer on good command
}
#endif
|
#include "IMPORT_0"
#include "IMPORT_1"
// serial control - mostly a remnant from the old serial camera board, some parts may not entirely work.
// useful for messing with camera & OLED commands etc. as well as getting live image data
// for image data you will probably want to crank up the baudrate to 2Mbaud or higher
#if VAR_0==1
unsigned int VAR_1;
void polluart(void) { // check for serial commands. Slightly crude but simple
unsigned int i, pchange, VAR_2, VAR_3, VAR_4;
unsigned char VAR_5;
if (tick) {
if (VAR_6) if (++VAR_7 > 2) VAR_6 = 0; // serial receive timeout
if (VAR_8.VAR_9) {
VAR_8.VAR_9 = 0;
VAR_6 = 0;
} // UART overrun
if (VAR_8.VAR_10) {
VAR_8.VAR_10 = 0;
VAR_6 = 0;
} // Framing error
}
if (VAR_6 == 0) return;
switch (rxbuf[0]) {
case 0x10:// 0x10 <adr> <value> set camera register. returns 0x55
if (VAR_6 != 3) break;
VAR_6 = 0;
FUNC_0(rxbuf[1], rxbuf[2]);
u2txbyte(0x55);
break;
case 0x11: // 0x11 <rr> read camera register. returns 1 byte register value
if (VAR_6 != 2) break;
VAR_6 = 0;
u2txbyte(readcamreg(rxbuf[1]));
break;
case 0x13: // 0x12 <en> <graben> camera enable/disable
if (VAR_6 != 3) break;
VAR_6=0;
cam_enable(rxbuf[1]);
FUNC_1(rxbuf[2],0,0);
u2txbyte(0x55);
break;
case 0x14: // 14 xstart/2 ystart/2 xdiv ydiv refclkdiv set capture parameters 0 = unchanged
if (VAR_6 != 6) break;
VAR_6 = 0;
if (rxbuf[1]) VAR_11 = (unsigned int) rxbuf[1]*2;
if (rxbuf[2])VAR_12 = (unsigned int) rxbuf[2]*2;
if (rxbuf[3])xdiv = (unsigned int) rxbuf[3];
if (rxbuf[4])ydiv = (unsigned int) rxbuf[4];
if (rxbuf[5]) VAR_13 = 0b1001001000000000 | ((unsigned int) rxbuf[5]) << 16; // XCLK clock to cam
u2txbyte(0x55);
break;
case 0x15 : // 15 poll camera state
if(VAR_6!=1) break;
VAR_6=0;
u2txbyte(cam_newframe?1:0 | cam_busy?2:0 | cam_wrap?4:0 | VAR_14?8:0);
FUNC_2(linecnt);
FUNC_2(camaddr);
break;
case 0x16 : // 16 xx return image. xx=1 to wait for new frame
// could be optimised by starting to send while capture in progress
if(VAR_6!=2) break;
VAR_6=0;
if(rxbuf[1]) while(!cam_newframe);
for(VAR_2=1,i=0;i!=VAR_15*ypixels*(VAR_16 & camopt_mono)?1:2;i++) {
VAR_17;
u2txbyte(cambuffer[VAR_2++]);
}
cam_newframe=0;
break;
case 0x20: // return info
if(VAR_6!=1) break;
VAR_6=0;
u2txbyte(VAR_18);
u2txbyte(VAR_19 / 1000000);
u2txbyte(VAR_20 >> 16);
u2txbyte(VAR_20 >> 8);
u2txbyte(VAR_20 & 0xff);
VAR_6 = 0;
break;
case 0x30: // 30 return accel data, bat level, bat state
if(VAR_6!=1) break;
VAR_6=0;
FUNC_2(accx);
FUNC_2(VAR_21);
FUNC_2(accz);
u2txbyte(butstate);
u2txbyte(butpress);
FUNC_2(VAR_22);
break;
}//switch
if (VAR_6 == 0) VAR_23 = 0; // reset timer on good command
}
#endif
| 0.657708 | {'IMPORT_0': 'cambadge.h', 'IMPORT_1': 'globals.h', 'VAR_0': 'serialcontrol', 'VAR_1': 'camoptions', 'VAR_2': 'x', 'VAR_3': 'y', 'VAR_4': 'outptr', 'VAR_5': 'c', 'VAR_6': 'rxptr', 'VAR_7': 'rxtimer', 'VAR_8': 'U2STAbits', 'VAR_9': 'OERR', 'VAR_10': 'FERR', 'FUNC_0': 'cam_setreg', 'FUNC_1': 'cam_grabenable', 'VAR_11': 'xstart', 'VAR_12': 'ystart', 'VAR_13': 'REFOCON', 'VAR_14': 'cam_started', 'FUNC_2': 'u2txword', 'VAR_15': 'xpixels', 'VAR_16': 'camflags', 'VAR_17': 'kickwatchdog', 'VAR_18': 'versionbyte', 'VAR_19': 'clockfreq', 'VAR_20': 'cambufsize', 'VAR_21': 'accy', 'VAR_22': 'battlevel', 'VAR_23': 'powerdowntimer'} |
/*
* Copyright 2021 MusicScience37 (<NAME>)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*!
* \file
* \brief Definition of IReporter class.
*/
#pragma once
#include <exception>
#include "stat_bench/bench/benchmark_case_info.h"
#include "stat_bench/bench/benchmark_condition.h"
#include "stat_bench/clock/system_time_point.h"
#include "stat_bench/measurer/measurement.h"
namespace stat_bench {
namespace reporter {
/*!
* \brief Interface of reporters.
*/
class IReporter {
public:
/*!
* \brief Start an experiment.
*
* \param[in] time_stamp Time stamp.
*/
virtual void experiment_starts(
const clock::SystemTimePoint& time_stamp) = 0;
/*!
* \brief Finished an experiment.
*
* \param[in] time_stamp Time stamp.
*/
virtual void experiment_finished(
const clock::SystemTimePoint& time_stamp) = 0;
/*!
* \brief Start benchmarks using a measurer.
*
* \param[in] name Measurer name.
*/
virtual void measurer_starts(const std::string& name) = 0;
/*!
* \brief Finished benchmarks using a measurer.
*
* \param[in] name Measurer name.
*/
virtual void measurer_finished(const std::string& name) = 0;
/*!
* \brief Start a group of benchmarks.
*
* \param[in] name Group name.
*/
virtual void group_starts(const std::string& name) = 0;
/*!
* \brief Finished a group of benchmarks.
*
* \param[in] name Group name.
*/
virtual void group_finished(const std::string& name) = 0;
/*!
* \brief Start a case of a benchmark.
*
* \param[in] case_info Information.
*/
virtual void case_starts(const bench::BenchmarkCaseInfo& case_info) = 0;
/*!
* \brief Finished a case of a benchmark.
*
* \param[in] case_info Information.
*/
virtual void case_finished(const bench::BenchmarkCaseInfo& case_info) = 0;
/*!
* \brief Successfully finished a measurement.
*
* \param[in] measurement Measurement.
*/
virtual void measurement_succeeded(
const measurer::Measurement& measurement) = 0;
/*!
* \brief Failed a measurement.
*
* \param[in] case_info Information of the case.
* \param[in] cond Condition.
* \param[in] error Error.
*/
virtual void measurement_failed(const bench::BenchmarkCaseInfo& case_info,
const bench::BenchmarkCondition& cond,
const std::exception_ptr& error) = 0;
IReporter(const IReporter&) = delete;
IReporter(IReporter&&) = delete;
auto operator=(const IReporter&) -> IReporter& = delete;
auto operator=(IReporter&&) -> IReporter& = delete;
/*!
* \brief Destructor.
*/
virtual ~IReporter() = default;
protected:
/*!
* \brief Constructor.
*/
IReporter() = default;
};
} // namespace reporter
} // namespace stat_bench
| /*
* Copyright 2021 MusicScience37 (<NAME>)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*!
* \file
* \brief Definition of IReporter class.
*/
#pragma once
#include <exception>
#include "stat_bench/bench/benchmark_case_info.h"
#include "IMPORT_0"
#include "stat_bench/clock/system_time_point.h"
#include "stat_bench/measurer/measurement.h"
namespace stat_bench {
namespace reporter {
/*!
* \brief Interface of reporters.
*/
CLASS_0 IReporter {
public:
/*!
* \brief Start an experiment.
*
* \param[in] time_stamp Time stamp.
*/
virtual void experiment_starts(
const clock::SystemTimePoint& time_stamp) = 0;
/*!
* \brief Finished an experiment.
*
* \param[in] time_stamp Time stamp.
*/
virtual void experiment_finished(
const clock::SystemTimePoint& time_stamp) = 0;
/*!
* \brief Start benchmarks using a measurer.
*
* \param[in] name Measurer name.
*/
virtual void measurer_starts(const std::string& name) = 0;
/*!
* \brief Finished benchmarks using a measurer.
*
* \param[in] name Measurer name.
*/
virtual void FUNC_0(const std::string& name) = 0;
/*!
* \brief Start a group of benchmarks.
*
* \param[in] name Group name.
*/
virtual void group_starts(const std::string& name) = 0;
/*!
* \brief Finished a group of benchmarks.
*
* \param[in] name Group name.
*/
virtual void group_finished(const std::string& name) = 0;
/*!
* \brief Start a case of a benchmark.
*
* \param[in] case_info Information.
*/
virtual void case_starts(const bench::VAR_0& VAR_1) = 0;
/*!
* \brief Finished a case of a benchmark.
*
* \param[in] case_info Information.
*/
virtual void case_finished(const bench::VAR_0& VAR_1) = 0;
/*!
* \brief Successfully finished a measurement.
*
* \param[in] measurement Measurement.
*/
virtual void FUNC_1(
const CLASS_1::Measurement& measurement) = 0;
/*!
* \brief Failed a measurement.
*
* \param[in] case_info Information of the case.
* \param[in] cond Condition.
* \param[in] error Error.
*/
virtual void measurement_failed(const bench::VAR_0& VAR_1,
const bench::BenchmarkCondition& VAR_2,
const std::exception_ptr& error) = 0;
IReporter(const IReporter&) = delete;
IReporter(IReporter&&) = delete;
auto operator=(const IReporter&) -> IReporter& = delete;
auto operator=(IReporter&&) -> IReporter& = delete;
/*!
* \brief Destructor.
*/
virtual ~IReporter() = default;
protected:
/*!
* \brief Constructor.
*/
IReporter() = default;
};
} // namespace reporter
} // namespace stat_bench
| 0.291421 | {'IMPORT_0': 'stat_bench/bench/benchmark_condition.h', 'CLASS_0': 'class', 'FUNC_0': 'measurer_finished', 'VAR_0': 'BenchmarkCaseInfo', 'VAR_1': 'case_info', 'FUNC_1': 'measurement_succeeded', 'CLASS_1': 'measurer', 'VAR_2': 'cond'} |
/*
This file is part of Caelum.
See http://www.ogre3d.org/wiki/index.php/Caelum
Copyright (c) 2008 Caelum team. See Contributors.txt for details.
Caelum is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Caelum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Caelum. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CAELUM__OWNED_PTR_H
#define CAELUM__OWNED_PTR_H
#include "CaelumPrerequisites.h"
namespace Caelum
{
/** Default traits for Caelum::OwnedPtr.
*
* This default traits class make OwnedPtr work like std::auto_ptr.
* Other Traits classes can derive from this and only customize some of
* the functions.
*
* @see OwnedPtr
*/
template<class PointedT>
struct DefaultOwnedPtrTraits
{
/// The type of the inner member to hold in OwnedPtr
typedef PointedT* InnerPointerType;
/// Return an InnerPointerType repressenting a null value.
static inline const InnerPointerType getNullValue() {
return 0;
}
/// Convert InnerPointerType to a naked PointedT.
static inline PointedT* getPointer (const InnerPointerType& inner) {
return inner;
}
/// Destroy the inner value (and set null).
static void destroy (InnerPointerType& inner)
{
delete inner;
inner = 0;
}
};
/** Template for smart pointers with strict unique ownership.
* A lot of objects in Ogre are created and destroyed through other
* "Manager" objects. Even though the memory for such objects is never
* actually leaked better lifetime control is frequently useful.
*
* OwnedPtr is very similar in behaviour to std::auto_ptr but tries
* to mimic Ogre::SharedPtr method names. Only one OwnedPtr must exist to
* a certain object at any one time. Assignment and copy construction will
* in fact pass away ownership and set the original OwnedPtr to null.
*
* This very limited functionality makes OwnedPtr very efficient; it should
* have no overhead compared to doing the same thing manually.
*
* OwnedPtr supports customization through a static traits class which
* can customize what happens when the OwnedPtr is destroyed. This makes
* it possible to use OwnedPtr classes for fine control over the lifetime
* of objects which are otherwise managed by an external class.
*
* @see DefaultOwnedPtrTraits
*/
template<class PointedT, typename TraitsT = DefaultOwnedPtrTraits<PointedT> >
class OwnedPtr
{
private:
/// Brings InnerPointerType as a type in this scope.
typedef typename TraitsT::InnerPointerType InnerPointerType;
/// Inner data member.
InnerPointerType mInner;
public:
/** Change the inner value.
* This will destroy the old value and gain ownership of the new value.
*/
void reset (const InnerPointerType& newInner = TraitsT::getNullValue()) {
if (mInner == newInner) {
return;
}
TraitsT::destroy (mInner);
mInner = newInner;
}
/** Constructor; always initialize to 0.
*/
OwnedPtr() { mInner = TraitsT::getNullValue (); }
/** Non-virtual destructor (don't derive from this).
*/
~OwnedPtr() { setNull(); }
/** Copy constructor; clears right-hand-side.
*/
OwnedPtr(OwnedPtr& rhs)
{
if (&rhs != this) {
this->reset (rhs.mInner);
rhs.mInner = TraitsT::getNullValue ();
}
}
/** Assignment
*/
const OwnedPtr& operator=(OwnedPtr& rhs)
{
if (&rhs != this) {
this->reset (rhs.mInner);
rhs.mInner = TraitsT::getNullValue ();
}
return *this;
}
/// Check if this is null.
bool isNull () const { return mInner != TraitsT::getNullValue (); }
/// Set to null and destroy contents (if any).
void setNull () { TraitsT::destroy (mInner); }
PointedT* getPointer () const { return TraitsT::getPointer (mInner); }
PointedT* get () const { return getPointer (); }
PointedT* operator-> () const { return getPointer (); }
PointedT& operator* () const{ return *getPointer (); }
};
/** Owned ptr traits for a movable object.
* This kind of pointer will remove the movable from the scene and destroy it.
*/
template<class MovableT>
struct MovableObjectOwnedPtrTraits: public DefaultOwnedPtrTraits<MovableT>
{
typedef MovableT* InnerPointerType;
static void destroy (InnerPointerType& inner)
{
if (inner != 0) {
//Ogre::LogManager::getSingletonPtr ()->logMessage (
// "OwnedPtr: Destroying movable object " + inner->getName ());
inner->_getManager ()->destroyMovableObject (inner);
inner = 0;
}
}
};
typedef OwnedPtr<Ogre::MovableObject, MovableObjectOwnedPtrTraits<Ogre::MovableObject> > MovableObjectPtr;
typedef OwnedPtr<Ogre::BillboardChain, MovableObjectOwnedPtrTraits<Ogre::BillboardChain> > BillboardChainPtr;
typedef OwnedPtr<Ogre::BillboardSet, MovableObjectOwnedPtrTraits<Ogre::BillboardSet> > BillboardSetPtr;
typedef OwnedPtr<Ogre::Entity, MovableObjectOwnedPtrTraits<Ogre::Entity> > EntityPtr;
typedef OwnedPtr<Ogre::Light, MovableObjectOwnedPtrTraits<Ogre::Light> > LightPtr;
typedef OwnedPtr<Ogre::ManualObject, MovableObjectOwnedPtrTraits<Ogre::ManualObject> > ManualObjectPtr;
typedef OwnedPtr<Ogre::ParticleSystem, MovableObjectOwnedPtrTraits<Ogre::ParticleSystem> > ParticleSystemPtr;
/** Owned ptr traits for a scene node.
* Scene nodes are created and destroyed through the scene manager.
* @see SceneNodePtr
*/
struct SceneNodeOwnedPtrTraits: public DefaultOwnedPtrTraits<Ogre::SceneNode>
{
static void destroy (InnerPointerType& inner)
{
if (inner) {
//Ogre::LogManager::getSingletonPtr ()->logMessage (
// "OwnedPtr: Destroying scene node " + inner->getName ());
inner->getCreator ()->destroySceneNode (inner->getName ());
inner = 0;
}
}
};
typedef OwnedPtr<Ogre::SceneNode, SceneNodeOwnedPtrTraits> SceneNodePtr;
/** OwnedPtr traits for uniquely-owned resources.
*
* All ogre resources are tracked by a resource managed by name and can
* be globally referenced from multiple places. This traits class allows
* you to hold a pointer to a resource which you create and completely
* control.
*
* The best example of this is a cloned material. It is frequently useful
* to create a clone of an existing material and tweak settings for one
* particular usage. After the clone is no longer useful the material must
* be explicitly removed from the MaterialManager. Otherwise an unloaded
* resource handle is leaked.
*
* When the OwnedPtr gets out of scope the resource is removed from the
* manager. In debug mode this will also check that there are no other
* references to the destroyed resource.
*/
template<class PointedT, class InnerT, class ManagerT>
struct OwnedResourcePtrTraits
{
typedef InnerT InnerPointerType;
static const InnerT getNullValue () {
return InnerT();
}
static PointedT* getPointer (const InnerPointerType& inner) {
return inner.getPointer ();
}
static void destroy (InnerPointerType& inner) {
if (!inner.isNull ()) {
//Ogre::LogManager::getSingletonPtr ()->logMessage (
// "OwnedPtr: Destroying owned resource " + inner->getName ());
ManagerT::getSingletonPtr ()->remove (inner->getHandle ());
assert (inner.unique () && "Resource pointer not unique after destruction");
}
}
};
typedef OwnedPtr <
Ogre::Material,
OwnedResourcePtrTraits <
Ogre::Material,
Ogre::MaterialPtr,
Ogre::MaterialManager
>
> OwnedMaterialPtr;
typedef OwnedPtr <
Ogre::Mesh,
OwnedResourcePtrTraits <
Ogre::Mesh,
Ogre::MeshPtr,
Ogre::MeshManager
>
> OwnedMeshPtr;
}
#endif // CAELUM__OWNED_PTR_H
| /*
This file is part of Caelum.
See http://www.ogre3d.org/wiki/index.php/Caelum
Copyright (c) 2008 Caelum team. See Contributors.txt for details.
Caelum is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Caelum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Caelum. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VAR_0
#define VAR_0
#include "CaelumPrerequisites.h"
CLASS_0 VAR_1
{
/** Default traits for Caelum::OwnedPtr.
*
* This default traits class make OwnedPtr work like std::auto_ptr.
* Other Traits classes can derive from this and only customize some of
* the functions.
*
* @see OwnedPtr
*/
template<class PointedT>
struct VAR_2
{
/// The type of the inner member to hold in OwnedPtr
typedef PointedT* InnerPointerType;
/// Return an InnerPointerType repressenting a null value.
static inline const InnerPointerType FUNC_0() {
return 0;
}
/// Convert InnerPointerType to a naked PointedT.
static inline PointedT* FUNC_1 (const InnerPointerType& inner) {
return inner;
}
/// Destroy the inner value (and set null).
static void destroy (InnerPointerType& inner)
{
delete inner;
inner = 0;
}
};
/** Template for smart pointers with strict unique ownership.
* A lot of objects in Ogre are created and destroyed through other
* "Manager" objects. Even though the memory for such objects is never
* actually leaked better lifetime control is frequently useful.
*
* OwnedPtr is very similar in behaviour to std::auto_ptr but tries
* to mimic Ogre::SharedPtr method names. Only one OwnedPtr must exist to
* a certain object at any one time. Assignment and copy construction will
* in fact pass away ownership and set the original OwnedPtr to null.
*
* This very limited functionality makes OwnedPtr very efficient; it should
* have no overhead compared to doing the same thing manually.
*
* OwnedPtr supports customization through a static traits class which
* can customize what happens when the OwnedPtr is destroyed. This makes
* it possible to use OwnedPtr classes for fine control over the lifetime
* of objects which are otherwise managed by an external class.
*
* @see DefaultOwnedPtrTraits
*/
template<class PointedT, VAR_4 TraitsT = VAR_2<PointedT> >
class OwnedPtr
{
private:
/// Brings InnerPointerType as a type in this scope.
VAR_5 VAR_4 TraitsT::InnerPointerType InnerPointerType;
/// Inner data member.
InnerPointerType mInner;
public:
/** Change the inner value.
* This will destroy the old value and gain ownership of the new value.
*/
void VAR_6 (const InnerPointerType& newInner = TraitsT::FUNC_0()) {
if (mInner == newInner) {
return;
}
TraitsT::destroy (mInner);
mInner = newInner;
}
/** Constructor; always initialize to 0.
*/
OwnedPtr() { mInner = TraitsT::VAR_3 (); }
/** Non-virtual destructor (don't derive from this).
*/
~OwnedPtr() { FUNC_3(); }
/** Copy constructor; clears right-hand-side.
*/
OwnedPtr(OwnedPtr& VAR_7)
{
if (&VAR_7 != this) {
this->FUNC_2 (VAR_7.mInner);
VAR_7.mInner = TraitsT::VAR_3 ();
}
}
/** Assignment
*/
const OwnedPtr& operator=(OwnedPtr& VAR_7)
{
if (&VAR_7 != this) {
this->FUNC_2 (VAR_7.mInner);
VAR_7.mInner = TraitsT::VAR_3 ();
}
return *this;
}
/// Check if this is null.
bool FUNC_4 () const { return mInner != TraitsT::VAR_3 (); }
/// Set to null and destroy contents (if any).
void FUNC_3 () { TraitsT::destroy (mInner); }
PointedT* FUNC_1 () const { return TraitsT::FUNC_1 (mInner); }
PointedT* get () const { return FUNC_1 (); }
PointedT* operator->FUNC_5 () const { return FUNC_1 (); }
PointedT& operator* () const{ return *FUNC_1 (); }
};
/** Owned ptr traits for a movable object.
* This kind of pointer will remove the movable from the scene and destroy it.
*/
template<class VAR_8>
struct MovableObjectOwnedPtrTraits: public VAR_2<VAR_8>
{
typedef CLASS_1* InnerPointerType;
static void destroy (InnerPointerType& inner)
{
if (inner != 0) {
//Ogre::LogManager::getSingletonPtr ()->logMessage (
// "OwnedPtr: Destroying movable object " + inner->getName ());
inner->_getManager ()->FUNC_6 (inner);
inner = 0;
}
}
};
typedef OwnedPtr<CLASS_2::ID_1, ID_0<VAR_9::VAR_10> > VAR_11;
typedef OwnedPtr<CLASS_2::ID_2, ID_0<VAR_9::VAR_12> > BillboardChainPtr;
typedef OwnedPtr<CLASS_2::BillboardSet, ID_0<VAR_9::BillboardSet> > VAR_13;
typedef OwnedPtr<CLASS_2::Entity, ID_0<VAR_9::Entity> > VAR_14;
typedef OwnedPtr<CLASS_2::Light, ID_0<VAR_9::Light> > VAR_15;
typedef OwnedPtr<CLASS_2::ManualObject, ID_0<VAR_9::ManualObject> > VAR_16;
typedef OwnedPtr<CLASS_2::ID_3, ID_0<VAR_9::VAR_17> > VAR_18;
/** Owned ptr traits for a scene node.
* Scene nodes are created and destroyed through the scene manager.
* @see SceneNodePtr
*/
struct SceneNodeOwnedPtrTraits: public VAR_2<VAR_9::SceneNode>
{
static void destroy (InnerPointerType& inner)
{
if (inner) {
//Ogre::LogManager::getSingletonPtr ()->logMessage (
// "OwnedPtr: Destroying scene node " + inner->getName ());
inner->FUNC_7 ()->destroySceneNode (inner->FUNC_8 ());
inner = 0;
}
}
};
typedef OwnedPtr<CLASS_2::SceneNode, SceneNodeOwnedPtrTraits> VAR_19;
/** OwnedPtr traits for uniquely-owned resources.
*
* All ogre resources are tracked by a resource managed by name and can
* be globally referenced from multiple places. This traits class allows
* you to hold a pointer to a resource which you create and completely
* control.
*
* The best example of this is a cloned material. It is frequently useful
* to create a clone of an existing material and tweak settings for one
* particular usage. After the clone is no longer useful the material must
* be explicitly removed from the MaterialManager. Otherwise an unloaded
* resource handle is leaked.
*
* When the OwnedPtr gets out of scope the resource is removed from the
* manager. In debug mode this will also check that there are no other
* references to the destroyed resource.
*/
template<class PointedT, class InnerT, class VAR_20>
struct VAR_21
{
typedef InnerT InnerPointerType;
static const InnerT FUNC_0 () {
return InnerT();
}
static PointedT* FUNC_1 (const InnerPointerType& inner) {
return inner.FUNC_1 ();
}
static void destroy (InnerPointerType& inner) {
if (!inner.FUNC_4 ()) {
//Ogre::LogManager::getSingletonPtr ()->logMessage (
// "OwnedPtr: Destroying owned resource " + inner->getName ());
ManagerT::FUNC_9 ()->FUNC_10 (inner->FUNC_11 ());
assert (inner.FUNC_12 () && "Resource pointer not unique after destruction");
}
}
};
typedef OwnedPtr <
CLASS_2::Material,
CLASS_3 <
CLASS_2::Material,
CLASS_2::MaterialPtr,
CLASS_2::CLASS_4
>
> OwnedMaterialPtr;
typedef OwnedPtr <
CLASS_2::Mesh,
CLASS_3 <
CLASS_2::Mesh,
CLASS_2::MeshPtr,
CLASS_2::MeshManager
>
> ID_4;
}
#endif // CAELUM__OWNED_PTR_H
| 0.492673 | {'VAR_0': 'CAELUM__OWNED_PTR_H', 'CLASS_0': 'namespace', 'VAR_1': 'Caelum', 'VAR_2': 'DefaultOwnedPtrTraits', 'FUNC_0': 'getNullValue', 'VAR_3': 'getNullValue', 'FUNC_1': 'getPointer', 'VAR_4': 'typename', 'VAR_5': 'typedef', 'VAR_6': 'reset', 'FUNC_2': 'reset', 'FUNC_3': 'setNull', 'VAR_7': 'rhs', 'FUNC_4': 'isNull', 'FUNC_5': '', 'VAR_8': 'MovableT', 'CLASS_1': 'MovableT', 'ID_0': 'MovableObjectOwnedPtrTraits', 'FUNC_6': 'destroyMovableObject', 'CLASS_2': 'Ogre', 'VAR_9': 'Ogre', 'ID_1': 'MovableObject', 'VAR_10': 'MovableObject', 'VAR_11': 'MovableObjectPtr', 'ID_2': 'BillboardChain', 'VAR_12': 'BillboardChain', 'VAR_13': 'BillboardSetPtr', 'VAR_14': 'EntityPtr', 'VAR_15': 'LightPtr', 'VAR_16': 'ManualObjectPtr', 'ID_3': 'ParticleSystem', 'VAR_17': 'ParticleSystem', 'VAR_18': 'ParticleSystemPtr', 'FUNC_7': 'getCreator', 'FUNC_8': 'getName', 'VAR_19': 'SceneNodePtr', 'VAR_20': 'ManagerT', 'VAR_21': 'OwnedResourcePtrTraits', 'CLASS_3': 'OwnedResourcePtrTraits', 'FUNC_9': 'getSingletonPtr', 'FUNC_10': 'remove', 'FUNC_11': 'getHandle', 'FUNC_12': 'unique', 'CLASS_4': 'MaterialManager', 'ID_4': 'OwnedMeshPtr'} |
/*
* @file UpdateCaller.h
*
* @author <NAME>
* @description Calls a custom function to be updated at a regular interval.
*/
#include<functional>
class UpdateCaller
{
public:
UpdateCaller(int linterval)
{
interval = linterval;
on_update_handler=NULL;
lastMS=0;
}
void update()
{
unsigned long curMS = millis();
unsigned long diffMS = 0;
if(curMS > lastMS)
{
diffMS = curMS-lastMS;
if(diffMS >= interval)
{
lastMS = curMS;
callUpdater(diffMS);
}
}
else
{
diffMS = 4294967296-lastMS;
diffMS+=curMS;
if(diffMS >= interval)
{
lastMS = curMS;
callUpdater(diffMS);
}
}
}
void SetUpdateHandler(std::function<void (void)> lupdater)
{
on_update_handler=lupdater;
}
protected:
void callUpdater(unsigned long diffMS)
{
if(on_update_handler != NULL)
{
on_update_handler();
}
}
private:
unsigned long interval;
unsigned long lastMS;
std::function<void (void)> on_update_handler;
};
| /*
* @file UpdateCaller.h
*
* @author <NAME>
* @description Calls a custom function to be updated at a regular interval.
*/
#include<IMPORT_0>
CLASS_0 VAR_0
{
public:
FUNC_0(VAR_1 VAR_2)
{
VAR_3 = VAR_2;
VAR_4=NULL;
lastMS=0;
}
void FUNC_2()
{
unsigned long VAR_5 = FUNC_3();
unsigned long diffMS = 0;
if(VAR_5 > lastMS)
{
diffMS = VAR_5-lastMS;
if(diffMS >= VAR_3)
{
lastMS = VAR_5;
FUNC_4(diffMS);
}
}
else
{
diffMS = 4294967296-lastMS;
diffMS+=VAR_5;
if(diffMS >= VAR_3)
{
lastMS = VAR_5;
FUNC_4(diffMS);
}
}
}
void FUNC_5(CLASS_1::FUNC_6<void (void)> VAR_8)
{
VAR_4=VAR_8;
}
protected:
VAR_9 VAR_6(unsigned long diffMS)
{
if(VAR_4 != NULL)
{
FUNC_1();
}
}
private:
VAR_10 long VAR_3;
unsigned long lastMS;
std::VAR_7<FUNC_7 (VAR_9)> VAR_4;
};
| 0.827746 | {'IMPORT_0': 'functional', 'CLASS_0': 'class', 'VAR_0': 'UpdateCaller', 'FUNC_0': 'UpdateCaller', 'VAR_1': 'int', 'VAR_2': 'linterval', 'VAR_3': 'interval', 'VAR_4': 'on_update_handler', 'FUNC_1': 'on_update_handler', 'FUNC_2': 'update', 'VAR_5': 'curMS', 'FUNC_3': 'millis', 'FUNC_4': 'callUpdater', 'VAR_6': 'callUpdater', 'FUNC_5': 'SetUpdateHandler', 'CLASS_1': 'std', 'FUNC_6': 'function', 'VAR_7': 'function', 'VAR_8': 'lupdater', 'VAR_9': 'void', 'FUNC_7': 'void', 'VAR_10': 'unsigned'} |
/*
Copyright (c) 2017 TOSHIBA Digital Solutions Corporation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SQL_JOB_COMMON_H_
#define SQL_JOB_COMMON_H_
#include "sql_task_context.h"
#include "data_store_common.h"
#include "cluster_common.h"
#include "sql_type.h"
typedef int32_t TaskId;
typedef int32_t InputId;
typedef int32_t AssignNo;
class SQLProcessor;
class TaskInfo;
class PartitionTable;
class SQLPreparedPlan;
class JobManager;
enum TaskExecutionStatus {
TASK_EXEC_PIPE,
TASK_EXEC_FINISH,
TASK_EXEC_NEXT,
TASK_EXEC_IDLE
};
static const int32_t UNDEF_TASKID = -1;
enum ControlType {
FW_CONTROL_DEPLOY,
FW_CONTROL_DEPLOY_SUCCESS,
FW_CONTROL_PIPE0,
FW_CONTROL_PIPE,
FW_CONTROL_PIPE_FINISH,
FW_CONTROL_FINISH,
FW_CONTROL_NEXT,
FW_CONTROL_EXECUTE_SUCCESS,
FW_CONTROL_CANCEL,
FW_CONTROL_CLOSE,
FW_CONTROL_ERROR,
FW_CONTROL_HEARTBEAT,
FW_CONTROL_UNDEF
};
struct JobId {
JobId() :
execId_(UNDEF_STATEMENTID),
versionId_(0) {}
JobId(ClientId &clientId, JobExecutionId execId) :
clientId_(clientId),
execId_(execId),
versionId_(0) {}
bool operator==(const JobId &id) const;
bool isValid() {
return (execId_ != UNDEF_STATEMENTID);
}
bool operator < (const JobId& id) const;
ClientId clientId_;
JobExecutionId execId_;
uint8_t versionId_;
void parse(
util::StackAllocator &alloc,
util::String &jobIdStr);
void toString(
util::StackAllocator &alloc,
util::String &str,
bool isClientIdOnly = false);
void set(
ClientId &clientId,
JobExecutionId execId,
uint8_t versionId = 0) {
clientId_ = clientId;
execId_ = execId;
versionId_ = versionId;
}
std::string dump(
util::StackAllocator &alloc,
bool isClientIdOnly = false);
};
class JobInfo {
public:
class Job;
typedef int32_t NodePosition;
struct GsNodeInfo {
GsNodeInfo(util::StackAllocator &alloc) :
alloc_(alloc),
address_(alloc),
port_(0),
nodeId_(0) {}
util::StackAllocator &alloc_;
util::String address_;
uint16_t port_;
NodeId nodeId_;
UTIL_OBJECT_CODER_ALLOC_CONSTRUCTOR;
UTIL_OBJECT_CODER_MEMBERS(address_, port_);
};
typedef util::Vector<GsNodeInfo*> GsNodeInfoList;
typedef util::Vector<TaskInfo*> TaskInfoList;
JobInfo(util::StackAllocator &alloc);
~JobInfo();
void setup(
int64_t expiredTime,
int64_t elapsedTime,
int64_t currentClockTime,
bool isSetJobTime,
bool isCoordinator);
TaskInfo *createTaskInfo(
SQLPreparedPlan *plan, size_t pos);
GsNodeInfo *createAssignInfo(
PartitionTable *pt,
NodeId nodeId,
bool isLocal,
JobManager *jobManager);
util::StackAllocator &alloc_;
GsNodeInfoList gsNodeInfoList_;
bool coordinator_;
int64_t queryTimeout_;
int64_t expiredTime_;
int64_t startTime_;
int64_t startMonotonicTime_;
bool isSetJobTime_;
TaskInfoList taskInfoList_;
TaskId resultTaskId_;
PartitionId pId_;
TaskOption option_;
util::XArray<uint8_t> outBuffer_;
util::XArrayOutStream<> outStream_;
Job *job_;
EventByteInStream *inStream_;
NoSQLSyncContext *syncContext_;
int32_t limitAssignNum_;
bool isExplainAnalyze_;
bool isRetry_;
ContainerType containerType_;
bool isSQL_;
double storeMemoryAgingSwapRate_;
util::TimeZone timezone_;
UTIL_OBJECT_CODER_ALLOC_CONSTRUCTOR;
UTIL_OBJECT_CODER_MEMBERS(
gsNodeInfoList_,
taskInfoList_,
queryTimeout_,
expiredTime_,
startTime_,
isSetJobTime_,
resultTaskId_,
pId_,
limitAssignNum_,
isExplainAnalyze_,
isRetry_,
UTIL_OBJECT_CODER_ENUM(containerType_),
isSQL_);
};
class TaskInfo {
public:
typedef util::Vector<uint32_t> ResourceList;
TaskInfo(util::StackAllocator &alloc);
void setSQLType(SQLType::Id sqlType);
void setPlanInfo(
SQLPreparedPlan *pPlan, size_t pos);
util::StackAllocator &alloc_;
TaskId taskId_;
AssignNo loadBalance_;
uint8_t type_;
int32_t nodePos_;
ResourceList inputList_;
ResourceList outputList_;
util::Vector< util::Vector<TupleList::TupleColumnType> > outColumnTypeList_;
util::Vector< util::Vector<TupleList::TupleColumnType> > inputTypeList_;
NodeId nodeId_;
SQLType::Id sqlType_;
bool isDml_;
UTIL_OBJECT_CODER_ALLOC_CONSTRUCTOR;
UTIL_OBJECT_CODER_MEMBERS(
taskId_,
loadBalance_,
type_,
nodePos_,
inputList_,
outputList_,
inputTypeList_,
UTIL_OBJECT_CODER_ENUM(sqlType_));
};
struct StatTaskProfilerInfo {
StatTaskProfilerInfo(
util::StackAllocator &alloc) :
id_(0),
inputId_(0),
name_(alloc),
status_(alloc),
startTime_(alloc) {}
int64_t id_;
int64_t inputId_;
util::String name_;
util::String status_;
util::String startTime_;
UTIL_OBJECT_CODER_MEMBERS(
id_, inputId_, name_, status_, startTime_);
};
struct StatJobProfilerInfo {
StatJobProfilerInfo(
util::StackAllocator &alloc,
JobId &targetJobId);
int64_t id_;
util::String startTime_;
util::String jobId_;
util::Vector<StatTaskProfilerInfo> taskProfs_;
UTIL_OBJECT_CODER_MEMBERS(
id_, jobId_, startTime_, taskProfs_);
};
struct TaskProfilerInfo {
TaskProfilerInfo() :
taskId_(0),
startTime_(0),
endTime_(0),
enableTimer_(false),
completed_(false) {}
int32_t taskId_;
TaskProfiler profiler_;
uint64_t startTime_;
uint64_t endTime_;
util::Stopwatch watch_;
bool enableTimer_;
bool completed_;
void init(
util::StackAllocator &alloc,
int32_t taskId,
int32_t size,
int32_t workerId,
bool enableTimer = false);
void incInputCount(int32_t inputId, size_t size);
void start();
void end();
void complete();
void setCustomProfile(SQLProcessor *processor);
UTIL_OBJECT_CODER_MEMBERS(taskId_, profiler_);
};
struct JobProfilerInfo {
JobProfilerInfo(util::StackAllocator &alloc) :
alloc_(alloc),
profilerList_(alloc) {}
util::StackAllocator &alloc_;
util::Vector<TaskProfilerInfo*> profilerList_;
UTIL_OBJECT_CODER_ALLOC_CONSTRUCTOR;
UTIL_OBJECT_CODER_MEMBERS(profilerList_);
};
typedef JobInfo::GsNodeInfo GsNodeInfo;
#endif
| /*
Copyright (c) 2017 TOSHIBA Digital Solutions Corporation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VAR_0
#define VAR_0
#include "IMPORT_0"
#include "IMPORT_1"
#include "IMPORT_2"
#include "IMPORT_3"
typedef int32_t ID_0;
typedef int32_t ID_1;
typedef int32_t ID_2;
CLASS_2 VAR_2;
CLASS_2 VAR_3;
CLASS_2 VAR_4;
CLASS_2 VAR_5;
CLASS_2 JobManager;
enum CLASS_7 {
VAR_6,
VAR_7,
VAR_8,
VAR_9
};
static const int32_t VAR_10 = -1;
enum CLASS_8 {
VAR_11,
VAR_12,
VAR_13,
VAR_14,
VAR_15,
VAR_16,
VAR_17,
VAR_18,
VAR_19,
VAR_20,
VAR_21,
VAR_22,
VAR_23
};
struct CLASS_9 {
VAR_24() :
CLASS_10(CLASS_11),
VAR_27(0) {}
CLASS_9(ClientId &VAR_28, CLASS_13 VAR_29) :
CLASS_15(CLASS_12),
CLASS_10(CLASS_14),
VAR_27(0) {}
bool VAR_31==(const VAR_24 &ID_3) const;
bool CLASS_16() {
return (CLASS_10 != VAR_26);
}
bool VAR_31 < (const CLASS_9& VAR_32) VAR_33;
ClientId VAR_30;
CLASS_13 VAR_25;
uint8_t VAR_27;
void VAR_34(
ID_4::ID_5 &VAR_37,
VAR_35::VAR_38 &VAR_39);
void VAR_40(
ID_4::VAR_36 &VAR_37,
VAR_35::VAR_38 &VAR_41,
bool VAR_42 = false);
void CLASS_19(
ClientId &VAR_28,
CLASS_13 VAR_29,
uint8_t VAR_43 = 0) {
VAR_30 = VAR_28;
VAR_25 = VAR_29;
VAR_27 = VAR_43;
}
VAR_44::VAR_45 FUNC_0(
CLASS_17::VAR_36 &VAR_37,
bool VAR_42 = false);
};
CLASS_2 VAR_46 {
public:
VAR_1 VAR_47;
typedef int32_t ID_6;
struct CLASS_21 {
CLASS_21(ID_4::VAR_36 &VAR_37) :
FUNC_2(VAR_37),
VAR_50(CLASS_18),
VAR_51(0),
VAR_52(0) {}
VAR_35::VAR_36 &VAR_49;
CLASS_17::VAR_38 VAR_50;
uint16_t VAR_51;
CLASS_22 VAR_52;
CLASS_23;
VAR_54(ID_7, VAR_51);
};
typedef CLASS_17::CLASS_25<CLASS_21*> ID_8;
typedef CLASS_17::CLASS_25<CLASS_4*> ID_9;
JobInfo(ID_4::VAR_36 &VAR_37);
~FUNC_1();
void setup(
int64_t VAR_56,
int64_t VAR_57,
int64_t VAR_58,
bool VAR_59,
bool VAR_60);
CLASS_4 *FUNC_4(
CLASS_6 *VAR_61, size_t VAR_62);
CLASS_21 *createAssignInfo(
CLASS_5 *pt,
CLASS_22 VAR_63,
bool VAR_64,
JobManager *VAR_65);
util::VAR_36 &VAR_49;
CLASS_26 VAR_66;
bool VAR_67;
int64_t VAR_68;
int64_t VAR_69;
int64_t VAR_70;
int64_t VAR_71;
bool VAR_72;
CLASS_27 VAR_73;
CLASS_0 VAR_74;
CLASS_28 VAR_75;
CLASS_29 VAR_76;
util::XArray<VAR_77> VAR_78;
VAR_35::XArrayOutStream<> VAR_79;
CLASS_20 *VAR_80;
CLASS_30 *VAR_81;
NoSQLSyncContext *VAR_82;
int32_t VAR_83;
bool VAR_84;
bool VAR_85;
CLASS_31 VAR_86;
bool VAR_87;
double VAR_88;
util::VAR_89 VAR_90;
VAR_53;
FUNC_3(
VAR_66,
VAR_73,
VAR_68,
VAR_69,
VAR_70,
VAR_72,
VAR_74,
VAR_75,
VAR_83,
VAR_84,
VAR_85,
FUNC_5(VAR_86),
VAR_87);
};
CLASS_2 VAR_3 {
public:
typedef VAR_35::VAR_55<VAR_91> VAR_92;
TaskInfo(ID_4::VAR_36 &VAR_37);
void FUNC_6(CLASS_33::VAR_93 VAR_94);
void FUNC_7(
CLASS_6 *VAR_95, size_t VAR_62);
util::VAR_36 &VAR_49;
CLASS_0 VAR_96;
CLASS_1 VAR_97;
uint8_t VAR_98;
int32_t VAR_99;
CLASS_32 inputList_;
CLASS_32 VAR_100;
VAR_35::VAR_55< VAR_35::VAR_55<VAR_101::VAR_102> > VAR_103;
VAR_35::VAR_55< VAR_35::VAR_55<VAR_101::VAR_102> > VAR_104;
CLASS_22 VAR_52;
SQLType::VAR_93 VAR_105;
bool VAR_106;
VAR_53;
FUNC_3(
VAR_96,
VAR_97,
VAR_98,
VAR_99,
inputList_,
VAR_100,
VAR_104,
FUNC_5(VAR_105));
};
struct CLASS_35 {
VAR_107(
ID_4::ID_5 &VAR_37)VAR_108 :
FUNC_8(0),
VAR_110(0),
VAR_111(CLASS_18),
VAR_112(CLASS_18),
VAR_70(CLASS_18) {}
int64_t VAR_109;
int64_t VAR_110;
CLASS_17::VAR_38 VAR_111;
CLASS_17::VAR_38 VAR_112;
CLASS_17::VAR_38 VAR_70;
VAR_54(
ID_11, ID_12, ID_13, ID_14, ID_10);
};
struct CLASS_36 {
VAR_113(
ID_4::ID_5 &VAR_37,
VAR_24 &VAR_114);
int64_t VAR_109;
CLASS_17::VAR_38 VAR_70;
CLASS_17::VAR_38 jobId_;
CLASS_17::VAR_55<VAR_107> VAR_115;
VAR_54(
ID_11, jobId_, ID_10, ID_15);
};
struct VAR_116 {
VAR_116() :
VAR_96(0),
VAR_70(0),
VAR_117(0),
CLASS_37(CLASS_38),
VAR_119(ID_16) {}
int32_t VAR_96;
TaskProfiler VAR_120;
uint64_t VAR_70;
uint64_t VAR_117;
ID_4::CLASS_40 VAR_121;
bool VAR_118;
bool VAR_119;
void VAR_122(
ID_4::VAR_36 &VAR_37,
int32_t VAR_123,
int32_t VAR_124,
int32_t VAR_125,
bool VAR_126 = false);
void CLASS_41(int32_t VAR_127, size_t VAR_124);
void CLASS_42();
void CLASS_43();
void CLASS_44();
void CLASS_45(CLASS_3 *VAR_128);
CLASS_24(CLASS_34, CLASS_39);
};
struct CLASS_46 {
VAR_129(ID_4::ID_5 &VAR_37) :
VAR_49(CLASS_18),
VAR_130(CLASS_18) {}
VAR_35::VAR_36 &VAR_49;
CLASS_17::VAR_55<VAR_116*> VAR_130;
CLASS_23;
VAR_54(ID_17);
};
typedef VAR_46::VAR_48 VAR_48;
#endif
| 0.932965 | {'VAR_0': 'SQL_JOB_COMMON_H_', 'IMPORT_0': 'sql_task_context.h', 'IMPORT_1': 'data_store_common.h', 'IMPORT_2': 'cluster_common.h', 'IMPORT_3': 'sql_type.h', 'ID_0': 'TaskId', 'CLASS_0': 'TaskId', 'ID_1': 'InputId', 'ID_2': 'AssignNo', 'CLASS_1': 'AssignNo', 'CLASS_2': 'class', 'VAR_1': 'class', 'VAR_2': 'SQLProcessor', 'CLASS_3': 'SQLProcessor', 'VAR_3': 'TaskInfo', 'CLASS_4': 'TaskInfo', 'VAR_4': 'PartitionTable', 'CLASS_5': 'PartitionTable', 'VAR_5': 'SQLPreparedPlan', 'CLASS_6': 'SQLPreparedPlan', 'CLASS_7': 'TaskExecutionStatus', 'VAR_6': 'TASK_EXEC_PIPE', 'VAR_7': 'TASK_EXEC_FINISH', 'VAR_8': 'TASK_EXEC_NEXT', 'VAR_9': 'TASK_EXEC_IDLE', 'VAR_10': 'UNDEF_TASKID', 'CLASS_8': 'ControlType', 'VAR_11': 'FW_CONTROL_DEPLOY', 'VAR_12': 'FW_CONTROL_DEPLOY_SUCCESS', 'VAR_13': 'FW_CONTROL_PIPE0', 'VAR_14': 'FW_CONTROL_PIPE', 'VAR_15': 'FW_CONTROL_PIPE_FINISH', 'VAR_16': 'FW_CONTROL_FINISH', 'VAR_17': 'FW_CONTROL_NEXT', 'VAR_18': 'FW_CONTROL_EXECUTE_SUCCESS', 'VAR_19': 'FW_CONTROL_CANCEL', 'VAR_20': 'FW_CONTROL_CLOSE', 'VAR_21': 'FW_CONTROL_ERROR', 'VAR_22': 'FW_CONTROL_HEARTBEAT', 'VAR_23': 'FW_CONTROL_UNDEF', 'CLASS_9': 'JobId', 'VAR_24': 'JobId', 'CLASS_10': 'execId_', 'VAR_25': 'execId_', 'CLASS_11': 'UNDEF_STATEMENTID', 'VAR_26': 'UNDEF_STATEMENTID', 'VAR_27': 'versionId_', 'VAR_28': 'clientId', 'CLASS_12': 'clientId', 'CLASS_13': 'JobExecutionId', 'VAR_29': 'execId', 'CLASS_14': 'execId', 'CLASS_15': 'clientId_', 'VAR_30': 'clientId_', 'VAR_31': 'operator', 'ID_3': 'id', 'VAR_32': 'id', 'CLASS_16': 'isValid', 'VAR_33': 'const', 'VAR_34': 'parse', 'ID_4': 'util', 'VAR_35': 'util', 'CLASS_17': 'util', 'ID_5': 'StackAllocator', 'VAR_36': 'StackAllocator', 'VAR_37': 'alloc', 'CLASS_18': 'alloc', 'VAR_38': 'String', 'VAR_39': 'jobIdStr', 'VAR_40': 'toString', 'VAR_41': 'str', 'VAR_42': 'isClientIdOnly', 'CLASS_19': 'set', 'VAR_43': 'versionId', 'VAR_44': 'std', 'VAR_45': 'string', 'FUNC_0': 'dump', 'VAR_46': 'JobInfo', 'FUNC_1': 'JobInfo', 'VAR_47': 'Job', 'CLASS_20': 'Job', 'ID_6': 'NodePosition', 'CLASS_21': 'GsNodeInfo', 'VAR_48': 'GsNodeInfo', 'FUNC_2': 'alloc_', 'VAR_49': 'alloc_', 'VAR_50': 'address_', 'ID_7': 'address_', 'VAR_51': 'port_', 'VAR_52': 'nodeId_', 'CLASS_22': 'NodeId', 'CLASS_23': 'UTIL_OBJECT_CODER_ALLOC_CONSTRUCTOR', 'VAR_53': 'UTIL_OBJECT_CODER_ALLOC_CONSTRUCTOR', 'VAR_54': 'UTIL_OBJECT_CODER_MEMBERS', 'FUNC_3': 'UTIL_OBJECT_CODER_MEMBERS', 'CLASS_24': 'UTIL_OBJECT_CODER_MEMBERS', 'CLASS_25': 'Vector', 'VAR_55': 'Vector', 'ID_8': 'GsNodeInfoList', 'CLASS_26': 'GsNodeInfoList', 'ID_9': 'TaskInfoList', 'CLASS_27': 'TaskInfoList', 'VAR_56': 'expiredTime', 'VAR_57': 'elapsedTime', 'VAR_58': 'currentClockTime', 'VAR_59': 'isSetJobTime', 'VAR_60': 'isCoordinator', 'FUNC_4': 'createTaskInfo', 'VAR_61': 'plan', 'VAR_62': 'pos', 'VAR_63': 'nodeId', 'VAR_64': 'isLocal', 'VAR_65': 'jobManager', 'VAR_66': 'gsNodeInfoList_', 'VAR_67': 'coordinator_', 'VAR_68': 'queryTimeout_', 'VAR_69': 'expiredTime_', 'VAR_70': 'startTime_', 'ID_10': 'startTime_', 'VAR_71': 'startMonotonicTime_', 'VAR_72': 'isSetJobTime_', 'VAR_73': 'taskInfoList_', 'VAR_74': 'resultTaskId_', 'CLASS_28': 'PartitionId', 'VAR_75': 'pId_', 'CLASS_29': 'TaskOption', 'VAR_76': 'option_', 'VAR_77': 'uint8_t', 'VAR_78': 'outBuffer_', 'VAR_79': 'outStream_', 'VAR_80': 'job_', 'CLASS_30': 'EventByteInStream', 'VAR_81': 'inStream_', 'VAR_82': 'syncContext_', 'VAR_83': 'limitAssignNum_', 'VAR_84': 'isExplainAnalyze_', 'VAR_85': 'isRetry_', 'CLASS_31': 'ContainerType', 'VAR_86': 'containerType_', 'VAR_87': 'isSQL_', 'VAR_88': 'storeMemoryAgingSwapRate_', 'VAR_89': 'TimeZone', 'VAR_90': 'timezone_', 'FUNC_5': 'UTIL_OBJECT_CODER_ENUM', 'VAR_91': 'uint32_t', 'VAR_92': 'ResourceList', 'CLASS_32': 'ResourceList', 'FUNC_6': 'setSQLType', 'CLASS_33': 'SQLType', 'VAR_93': 'Id', 'VAR_94': 'sqlType', 'FUNC_7': 'setPlanInfo', 'VAR_95': 'pPlan', 'VAR_96': 'taskId_', 'CLASS_34': 'taskId_', 'VAR_97': 'loadBalance_', 'VAR_98': 'type_', 'VAR_99': 'nodePos_', 'VAR_100': 'outputList_', 'VAR_101': 'TupleList', 'VAR_102': 'TupleColumnType', 'VAR_103': 'outColumnTypeList_', 'VAR_104': 'inputTypeList_', 'VAR_105': 'sqlType_', 'VAR_106': 'isDml_', 'CLASS_35': 'StatTaskProfilerInfo', 'VAR_107': 'StatTaskProfilerInfo', 'VAR_108': '', 'FUNC_8': 'id_', 'VAR_109': 'id_', 'ID_11': 'id_', 'VAR_110': 'inputId_', 'ID_12': 'inputId_', 'VAR_111': 'name_', 'ID_13': 'name_', 'VAR_112': 'status_', 'ID_14': 'status_', 'CLASS_36': 'StatJobProfilerInfo', 'VAR_113': 'StatJobProfilerInfo', 'VAR_114': 'targetJobId', 'VAR_115': 'taskProfs_', 'ID_15': 'taskProfs_', 'VAR_116': 'TaskProfilerInfo', 'VAR_117': 'endTime_', 'CLASS_37': 'enableTimer_', 'VAR_118': 'enableTimer_', 'CLASS_38': 'false', 'ID_16': 'false', 'VAR_119': 'completed_', 'VAR_120': 'profiler_', 'CLASS_39': 'profiler_', 'CLASS_40': 'Stopwatch', 'VAR_121': 'watch_', 'VAR_122': 'init', 'VAR_123': 'taskId', 'VAR_124': 'size', 'VAR_125': 'workerId', 'VAR_126': 'enableTimer', 'CLASS_41': 'incInputCount', 'VAR_127': 'inputId', 'CLASS_42': 'start', 'CLASS_43': 'end', 'CLASS_44': 'complete', 'CLASS_45': 'setCustomProfile', 'VAR_128': 'processor', 'CLASS_46': 'JobProfilerInfo', 'VAR_129': 'JobProfilerInfo', 'VAR_130': 'profilerList_', 'ID_17': 'profilerList_'} |
/*
* FloatMixer.h
* ------------
* Purpose: Floating point mixer classes
* Notes : (currently none)
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
#pragma once
#include "BuildSettings.h"
#include "MixerInterface.h"
#include "Resampler.h"
OPENMPT_NAMESPACE_BEGIN
template<int channelsOut, int channelsIn, typename out, typename in, int int2float>
struct IntToFloatTraits : public MixerTraits<channelsOut, channelsIn, out, in>
{
static_assert(std::numeric_limits<input_t>::is_integer, "Input must be integer");
static_assert(!std::numeric_limits<output_t>::is_integer, "Output must be floating point");
static MPT_CONSTEXPR11_FUN output_t Convert(const input_t x)
{
return static_cast<output_t>(x) * (static_cast<output_t>(1) / static_cast<output_t>(int2float));
}
};
typedef IntToFloatTraits<2, 1, mixsample_t, int8, -int8_min> Int8MToFloatS;
typedef IntToFloatTraits<2, 1, mixsample_t, int16, -int16_min> Int16MToFloatS;
typedef IntToFloatTraits<2, 2, mixsample_t, int8, -int8_min> Int8SToFloatS;
typedef IntToFloatTraits<2, 2, mixsample_t, int16, -int16_min> Int16SToFloatS;
//////////////////////////////////////////////////////////////////////////
// Interpolation templates
template<class Traits>
struct LinearInterpolation
{
MPT_FORCEINLINE void Start(const ModChannel &, const CResampler &) { }
MPT_FORCEINLINE void End(const ModChannel &) { }
MPT_FORCEINLINE void operator() (typename Traits::outbuf_t &outSample, const typename Traits::input_t * const inBuffer, const uint32 posLo)
{
static_assert(static_cast<int>(Traits::numChannelsIn) <= static_cast<int>(Traits::numChannelsOut), "Too many input channels");
const typename Traits::output_t fract = posLo / static_cast<typename Traits::output_t>(0x100000000); //CResampler::LinearTablef[posLo >> 24];
for(int i = 0; i < Traits::numChannelsIn; i++)
{
typename Traits::output_t srcVol = Traits::Convert(inBuffer[i]);
typename Traits::output_t destVol = Traits::Convert(inBuffer[i + Traits::numChannelsIn]);
outSample[i] = srcVol + fract * (destVol - srcVol);
}
}
};
template<class Traits>
struct FastSincInterpolation
{
MPT_FORCEINLINE void Start(const ModChannel &, const CResampler &) { }
MPT_FORCEINLINE void End(const ModChannel &) { }
MPT_FORCEINLINE void operator() (typename Traits::outbuf_t &outSample, const typename Traits::input_t * const inBuffer, const uint32 posLo)
{
static_assert(static_cast<int>(Traits::numChannelsIn) <= static_cast<int>(Traits::numChannelsOut), "Too many input channels");
const typename Traits::output_t *lut = CResampler::FastSincTablef + ((posLo >> 22) & 0x3FC);
for(int i = 0; i < Traits::numChannelsIn; i++)
{
outSample[i] =
lut[0] * Traits::Convert(inBuffer[i - Traits::numChannelsIn])
+ lut[1] * Traits::Convert(inBuffer[i])
+ lut[2] * Traits::Convert(inBuffer[i + Traits::numChannelsIn])
+ lut[3] * Traits::Convert(inBuffer[i + 2 * Traits::numChannelsIn]);
}
}
};
template<class Traits>
struct PolyphaseInterpolation
{
const typename Traits::output_t *sinc;
MPT_FORCEINLINE void Start(const ModChannel &chn, const CResampler &resampler)
{
sinc = (((chn.increment > SamplePosition(0x130000000ll)) || (chn.increment < -SamplePosition(-0x130000000ll))) ?
(((chn.increment > SamplePosition(0x180000000ll)) || (chn.increment < SamplePosition(-0x180000000ll))) ? resampler.gDownsample2x : resampler.gDownsample13x) : resampler.gKaiserSinc);
}
MPT_FORCEINLINE void End(const ModChannel &) { }
MPT_FORCEINLINE void operator() (typename Traits::outbuf_t &outSample, const typename Traits::input_t * const inBuffer, const uint32 posLo)
{
static_assert(static_cast<int>(Traits::numChannelsIn) <= static_cast<int>(Traits::numChannelsOut), "Too many input channels");
const typename Traits::output_t *lut = sinc + ((posLo >> (32 - SINC_PHASES_BITS)) & SINC_MASK) * SINC_WIDTH;
for(int i = 0; i < Traits::numChannelsIn; i++)
{
outSample[i] =
lut[0] * Traits::Convert(inBuffer[i - 3 * Traits::numChannelsIn])
+ lut[1] * Traits::Convert(inBuffer[i - 2 * Traits::numChannelsIn])
+ lut[2] * Traits::Convert(inBuffer[i - Traits::numChannelsIn])
+ lut[3] * Traits::Convert(inBuffer[i])
+ lut[4] * Traits::Convert(inBuffer[i + Traits::numChannelsIn])
+ lut[5] * Traits::Convert(inBuffer[i + 2 * Traits::numChannelsIn])
+ lut[6] * Traits::Convert(inBuffer[i + 3 * Traits::numChannelsIn])
+ lut[7] * Traits::Convert(inBuffer[i + 4 * Traits::numChannelsIn]);
}
}
};
template<class Traits>
struct FIRFilterInterpolation
{
const typename Traits::output_t *WFIRlut;
MPT_FORCEINLINE void Start(const ModChannel &, const CResampler &resampler)
{
WFIRlut = resampler.m_WindowedFIR.lut;
}
MPT_FORCEINLINE void End(const ModChannel &) { }
MPT_FORCEINLINE void operator() (typename Traits::outbuf_t &outSample, const typename Traits::input_t * const inBuffer, const uint32 posLo)
{
static_assert(static_cast<int>(Traits::numChannelsIn) <= static_cast<int>(Traits::numChannelsOut), "Too many input channels");
const typename Traits::output_t * const lut = WFIRlut + ((((posLo >> 16) + WFIR_FRACHALVE) >> WFIR_FRACSHIFT) & WFIR_FRACMASK);
for(int i = 0; i < Traits::numChannelsIn; i++)
{
outSample[i] =
lut[0] * Traits::Convert(inBuffer[i - 3 * Traits::numChannelsIn])
+ lut[1] * Traits::Convert(inBuffer[i - 2 * Traits::numChannelsIn])
+ lut[2] * Traits::Convert(inBuffer[i - Traits::numChannelsIn])
+ lut[3] * Traits::Convert(inBuffer[i])
+ lut[4] * Traits::Convert(inBuffer[i + Traits::numChannelsIn])
+ lut[5] * Traits::Convert(inBuffer[i + 2 * Traits::numChannelsIn])
+ lut[6] * Traits::Convert(inBuffer[i + 3 * Traits::numChannelsIn])
+ lut[7] * Traits::Convert(inBuffer[i + 4 * Traits::numChannelsIn]);
}
}
};
//////////////////////////////////////////////////////////////////////////
// Mixing templates (add sample to stereo mix)
template<class Traits>
struct NoRamp
{
typename Traits::output_t lVol, rVol;
MPT_FORCEINLINE void Start(const ModChannel &chn)
{
lVol = static_cast<Traits::output_t>(chn.leftVol) * (1.0f / 4096.0f);
rVol = static_cast<Traits::output_t>(chn.rightVol) * (1.0f / 4096.0f);
}
MPT_FORCEINLINE void End(const ModChannel &) { }
};
struct Ramp
{
int32 lRamp, rRamp;
MPT_FORCEINLINE void Start(const ModChannel &chn)
{
lRamp = chn.rampLeftVol;
rRamp = chn.rampRightVol;
}
MPT_FORCEINLINE void End(ModChannel &chn)
{
chn.rampLeftVol = lRamp; chn.leftVol = lRamp >> VOLUMERAMPPRECISION;
chn.rampRightVol = rRamp; chn.rightVol = rRamp >> VOLUMERAMPPRECISION;
}
};
// Legacy optimization: If chn.nLeftVol == chn.nRightVol, save one multiplication instruction
template<class Traits>
struct MixMonoFastNoRamp : public NoRamp<Traits>
{
MPT_FORCEINLINE void operator() (const typename Traits::outbuf_t &outSample, const ModChannel &chn, typename Traits::output_t * const outBuffer)
{
typename Traits::output_t vol = outSample[0] * lVol;
for(int i = 0; i < Traits::numChannelsOut; i++)
{
outBuffer[i] += vol;
}
}
};
template<class Traits>
struct MixMonoNoRamp : public NoRamp<Traits>
{
MPT_FORCEINLINE void operator() (const typename Traits::outbuf_t &outSample, const ModChannel &, typename Traits::output_t * const outBuffer)
{
outBuffer[0] += outSample[0] * lVol;
outBuffer[1] += outSample[0] * rVol;
}
};
template<class Traits>
struct MixMonoRamp : public Ramp
{
MPT_FORCEINLINE void operator() (const typename Traits::outbuf_t &outSample, const ModChannel &chn, typename Traits::output_t * const outBuffer)
{
// TODO volume is not float, can we optimize this?
lRamp += chn.leftRamp;
rRamp += chn.rightRamp;
outBuffer[0] += outSample[0] * (lRamp >> VOLUMERAMPPRECISION) * (1.0f / 4096.0f);
outBuffer[1] += outSample[0] * (rRamp >> VOLUMERAMPPRECISION) * (1.0f / 4096.0f);
}
};
template<class Traits>
struct MixStereoNoRamp : public NoRamp<Traits>
{
MPT_FORCEINLINE void operator() (const typename Traits::outbuf_t &outSample, const ModChannel &, typename Traits::output_t * const outBuffer)
{
outBuffer[0] += outSample[0] * lVol;
outBuffer[1] += outSample[1] * rVol;
}
};
template<class Traits>
struct MixStereoRamp : public Ramp
{
MPT_FORCEINLINE void operator() (const typename Traits::outbuf_t &outSample, const ModChannel &chn, typename Traits::output_t * const outBuffer)
{
// TODO volume is not float, can we optimize this?
lRamp += chn.leftRamp;
rRamp += chn.rightRamp;
outBuffer[0] += outSample[0] * (lRamp >> VOLUMERAMPPRECISION) * (1.0f / 4096.0f);
outBuffer[1] += outSample[1] * (rRamp >> VOLUMERAMPPRECISION) * (1.0f / 4096.0f);
}
};
//////////////////////////////////////////////////////////////////////////
// Filter templates
template<class Traits>
struct NoFilter
{
MPT_FORCEINLINE void Start(const ModChannel &) { }
MPT_FORCEINLINE void End(const ModChannel &) { }
MPT_FORCEINLINE void operator() (const typename Traits::outbuf_t &, const ModChannel &) { }
};
// Resonant filter
template<class Traits>
struct ResonantFilter
{
// Filter history
typename Traits::output_t fy[Traits::numChannelsIn][2];
MPT_FORCEINLINE void Start(const ModChannel &chn)
{
for(int i = 0; i < Traits::numChannelsIn; i++)
{
fy[i][0] = chn.nFilter_Y[i][0];
fy[i][1] = chn.nFilter_Y[i][1];
}
}
MPT_FORCEINLINE void End(ModChannel &chn)
{
for(int i = 0; i < Traits::numChannelsIn; i++)
{
chn.nFilter_Y[i][0] = fy[i][0];
chn.nFilter_Y[i][1] = fy[i][1];
}
}
// Filter values are clipped to double the input range
#define ClipFilter(x) Clamp(x, static_cast<Traits::output_t>(-2.0f), static_cast<Traits::output_t>(2.0f))
MPT_FORCEINLINE void operator() (typename Traits::outbuf_t &outSample, const ModChannel &chn)
{
static_assert(static_cast<int>(Traits::numChannelsIn) <= static_cast<int>(Traits::numChannelsOut), "Too many input channels");
for(int i = 0; i < Traits::numChannelsIn; i++)
{
typename Traits::output_t val = outSample[i] * chn.nFilter_A0 + ClipFilter(fy[i][0]) * chn.nFilter_B0 + ClipFilter(fy[i][1]) * chn.nFilter_B1;
fy[i][1] = fy[i][0];
fy[i][0] = val - (outSample[i] * chn.nFilter_HP);
outSample[i] = val;
}
}
#undef ClipFilter
};
OPENMPT_NAMESPACE_END
| /*
* FloatMixer.h
* ------------
* Purpose: Floating point mixer classes
* Notes : (currently none)
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
#pragma once
#include "BuildSettings.h"
#include "IMPORT_0"
#include "Resampler.h"
OPENMPT_NAMESPACE_BEGIN
template<int channelsOut, VAR_0 channelsIn, typename VAR_1, typename in, VAR_0 int2float>
struct VAR_2 : public MixerTraits<channelsOut, channelsIn, VAR_1, in>
{
static_assert(VAR_3::numeric_limits<input_t>::is_integer, "Input must be integer");
static_assert(!VAR_3::numeric_limits<VAR_4>::is_integer, "Output must be floating point");
static MPT_CONSTEXPR11_FUN VAR_4 FUNC_0(const input_t VAR_5)
{
return VAR_6<VAR_4>(ID_0) * (VAR_6<VAR_4>(1) / VAR_6<VAR_4>(int2float));
}
};
typedef VAR_2<2, 1, mixsample_t, int8, -int8_min> VAR_7;
typedef VAR_2<2, 1, mixsample_t, VAR_8, -int16_min> VAR_9;
typedef VAR_2<2, 2, mixsample_t, int8, -int8_min> VAR_10;
typedef VAR_2<2, 2, mixsample_t, VAR_8, -int16_min> VAR_11;
//////////////////////////////////////////////////////////////////////////
// Interpolation templates
template<class Traits>
struct LinearInterpolation
{
MPT_FORCEINLINE void FUNC_1(const CLASS_0 &, const CLASS_1 &) { }
MPT_FORCEINLINE void End(const CLASS_0 &) { }
MPT_FORCEINLINE void operator() (typename Traits::VAR_15 &VAR_16, const typename Traits::input_t * const VAR_17, const uint32 VAR_18)
{
static_assert(VAR_6<VAR_0>(Traits::numChannelsIn) <= VAR_6<VAR_0>(Traits::VAR_19), "Too many input channels");
const typename Traits::VAR_4 VAR_20 = VAR_18 / VAR_6<typename Traits::VAR_4>(0x100000000); //CResampler::LinearTablef[posLo >> 24];
for(int i = 0; i < Traits::numChannelsIn; i++)
{
typename Traits::VAR_4 VAR_21 = Traits::FUNC_0(VAR_17[i]);
typename Traits::VAR_4 destVol = Traits::FUNC_0(VAR_17[i + Traits::numChannelsIn]);
VAR_16[i] = VAR_21 + VAR_20 * (destVol - VAR_21);
}
}
};
template<class Traits>
struct FastSincInterpolation
{
MPT_FORCEINLINE void FUNC_1(const CLASS_0 &, const CLASS_1 &) { }
MPT_FORCEINLINE void End(const CLASS_0 &) { }
MPT_FORCEINLINE void operator() (typename Traits::VAR_15 &VAR_16, const typename Traits::input_t * const VAR_17, const uint32 VAR_18)
{
static_assert(VAR_6<VAR_0>(Traits::numChannelsIn) <= VAR_6<VAR_0>(Traits::VAR_19), "Too many input channels");
const typename Traits::VAR_4 *VAR_22 = VAR_14::VAR_23 + ((VAR_18 >> 22) & 0x3FC);
for(int i = 0; i < Traits::numChannelsIn; i++)
{
VAR_16[i] =
VAR_22[0] * Traits::FUNC_0(VAR_17[i - Traits::numChannelsIn])
+ VAR_22[1] * Traits::FUNC_0(VAR_17[i])
+ VAR_22[2] * Traits::FUNC_0(VAR_17[i + Traits::numChannelsIn])
+ VAR_22[3] * Traits::FUNC_0(VAR_17[i + 2 * Traits::numChannelsIn]);
}
}
};
template<class Traits>
struct PolyphaseInterpolation
{
const typename Traits::VAR_4 *VAR_24;
MPT_FORCEINLINE void FUNC_1(const CLASS_0 &VAR_25, const CLASS_1 &resampler)
{
VAR_24 = (((VAR_25.increment > FUNC_2(0x130000000ll)) || (VAR_25.increment < -FUNC_2(-0x130000000ll))) ?
(((VAR_25.increment > FUNC_2(0x180000000ll)) || (VAR_25.increment < FUNC_2(-0x180000000ll))) ? resampler.VAR_26 : resampler.gDownsample13x) : resampler.gKaiserSinc);
}
MPT_FORCEINLINE void End(const CLASS_0 &) { }
MPT_FORCEINLINE void operator() (typename Traits::VAR_15 &VAR_16, const typename Traits::input_t * const VAR_17, const uint32 VAR_18)
{
static_assert(VAR_6<VAR_0>(Traits::numChannelsIn) <= VAR_6<VAR_0>(Traits::VAR_19), "Too many input channels");
const typename Traits::VAR_4 *VAR_22 = VAR_24 + ((VAR_18 >> (32 - VAR_27)) & VAR_28) * SINC_WIDTH;
for(int i = 0; i < Traits::numChannelsIn; i++)
{
VAR_16[i] =
VAR_22[0] * Traits::FUNC_0(VAR_17[i - 3 * Traits::numChannelsIn])
+ VAR_22[1] * Traits::FUNC_0(VAR_17[i - 2 * Traits::numChannelsIn])
+ VAR_22[2] * Traits::FUNC_0(VAR_17[i - Traits::numChannelsIn])
+ VAR_22[3] * Traits::FUNC_0(VAR_17[i])
+ VAR_22[4] * Traits::FUNC_0(VAR_17[i + Traits::numChannelsIn])
+ VAR_22[5] * Traits::FUNC_0(VAR_17[i + 2 * Traits::numChannelsIn])
+ VAR_22[6] * Traits::FUNC_0(VAR_17[i + 3 * Traits::numChannelsIn])
+ VAR_22[7] * Traits::FUNC_0(VAR_17[i + 4 * Traits::numChannelsIn]);
}
}
};
template<class Traits>
struct VAR_29
{
const typename Traits::VAR_4 *VAR_30;
MPT_FORCEINLINE void FUNC_1(const CLASS_0 &, const CLASS_1 &resampler)
{
VAR_30 = resampler.m_WindowedFIR.VAR_22;
}
MPT_FORCEINLINE void End(const CLASS_0 &) { }
MPT_FORCEINLINE void operator() (typename Traits::VAR_15 &VAR_16, const typename Traits::input_t * const VAR_17, const uint32 VAR_18)
{
static_assert(VAR_6<VAR_0>(Traits::numChannelsIn) <= VAR_6<VAR_0>(Traits::VAR_19), "Too many input channels");
const typename Traits::VAR_4 * const VAR_22 = VAR_30 + ((((VAR_18 >> 16) + WFIR_FRACHALVE) >> WFIR_FRACSHIFT) & VAR_31);
for(int i = 0; i < Traits::numChannelsIn; i++)
{
VAR_16[i] =
VAR_22[0] * Traits::FUNC_0(VAR_17[i - 3 * Traits::numChannelsIn])
+ VAR_22[1] * Traits::FUNC_0(VAR_17[i - 2 * Traits::numChannelsIn])
+ VAR_22[2] * Traits::FUNC_0(VAR_17[i - Traits::numChannelsIn])
+ VAR_22[3] * Traits::FUNC_0(VAR_17[i])
+ VAR_22[4] * Traits::FUNC_0(VAR_17[i + Traits::numChannelsIn])
+ VAR_22[5] * Traits::FUNC_0(VAR_17[i + 2 * Traits::numChannelsIn])
+ VAR_22[6] * Traits::FUNC_0(VAR_17[i + 3 * Traits::numChannelsIn])
+ VAR_22[7] * Traits::FUNC_0(VAR_17[i + 4 * Traits::numChannelsIn]);
}
}
};
//////////////////////////////////////////////////////////////////////////
// Mixing templates (add sample to stereo mix)
template<class Traits>
struct NoRamp
{
typename Traits::VAR_4 VAR_32, rVol;
MPT_FORCEINLINE void FUNC_1(const CLASS_0 &VAR_25)
{
VAR_32 = VAR_6<Traits::VAR_4>(VAR_25.leftVol) * (1.0f / 4096.0f);
rVol = VAR_6<Traits::VAR_4>(VAR_25.VAR_33) * (1.0f / 4096.0f);
}
MPT_FORCEINLINE void End(const CLASS_0 &) { }
};
struct Ramp
{
int32 lRamp, VAR_34;
MPT_FORCEINLINE void VAR_12(const CLASS_0 &VAR_25)
{
lRamp = VAR_25.rampLeftVol;
CLASS_2 = VAR_25.VAR_35;
}
MPT_FORCEINLINE void End(CLASS_0 &VAR_25)
{
VAR_25.rampLeftVol = lRamp; VAR_25.leftVol = lRamp >> VAR_36;
VAR_25.VAR_35 = VAR_34; VAR_25.VAR_33 = VAR_34 >> VAR_36;
}
};
// Legacy optimization: If chn.nLeftVol == chn.nRightVol, save one multiplication instruction
template<class Traits>
struct MixMonoFastNoRamp : public NoRamp<Traits>
{
MPT_FORCEINLINE void operator() (const typename Traits::VAR_15 &VAR_16, const CLASS_0 &VAR_25, typename Traits::VAR_4 * const VAR_37)
{
typename Traits::VAR_4 vol = VAR_16[0] * VAR_32;
for(int i = 0; i < Traits::VAR_19; i++)
{
VAR_37[i] += vol;
}
}
};
template<class Traits>
struct VAR_38 : public NoRamp<Traits>
{
MPT_FORCEINLINE void operator() (const typename Traits::VAR_15 &VAR_16, const CLASS_0 &, typename Traits::VAR_4 * const VAR_37)
{
VAR_37[0] += VAR_16[0] * VAR_32;
VAR_37[1] += VAR_16[0] * rVol;
}
};
template<class Traits>
struct MixMonoRamp : public Ramp
{
MPT_FORCEINLINE void operator() (const typename Traits::VAR_15 &VAR_16, const CLASS_0 &VAR_25, typename Traits::VAR_4 * const VAR_37)
{
// TODO volume is not float, can we optimize this?
lRamp += VAR_25.VAR_39;
VAR_34 += VAR_25.VAR_40;
VAR_37[0] += VAR_16[0] * (lRamp >> VAR_36) * (1.0f / 4096.0f);
VAR_37[1] += VAR_16[0] * (VAR_34 >> VAR_36) * (1.0f / 4096.0f);
}
};
template<class Traits>
struct MixStereoNoRamp : public NoRamp<Traits>
{
MPT_FORCEINLINE void operator() (const typename Traits::VAR_15 &VAR_16, const CLASS_0 &, typename Traits::VAR_4 * const VAR_37)
{
VAR_37[0] += VAR_16[0] * VAR_32;
VAR_37[1] += VAR_16[1] * rVol;
}
};
template<class Traits>
struct MixStereoRamp : public Ramp
{
MPT_FORCEINLINE void operator() (const typename Traits::VAR_15 &VAR_16, const CLASS_0 &VAR_25, typename Traits::VAR_4 * const VAR_37)
{
// TODO volume is not float, can we optimize this?
lRamp += VAR_25.VAR_39;
VAR_34 += VAR_25.VAR_40;
VAR_37[0] += VAR_16[0] * (lRamp >> VAR_36) * (1.0f / 4096.0f);
VAR_37[1] += VAR_16[1] * (VAR_34 >> VAR_36) * (1.0f / 4096.0f);
}
};
//////////////////////////////////////////////////////////////////////////
// Filter templates
template<class Traits>
struct NoFilter
{
MPT_FORCEINLINE void FUNC_1(const CLASS_0 &) { }
MPT_FORCEINLINE void End(const CLASS_0 &) { }
MPT_FORCEINLINE void operator() (const typename Traits::VAR_15 &, const CLASS_0 &) { }
};
// Resonant filter
template<class Traits>
struct ResonantFilter
{
// Filter history
typename Traits::VAR_4 fy[Traits::numChannelsIn][2];
MPT_FORCEINLINE void FUNC_1(const CLASS_0 &VAR_25)
{
for(int i = 0; i < Traits::numChannelsIn; i++)
{
fy[i][0] = VAR_25.nFilter_Y[i][0];
fy[i][1] = VAR_25.nFilter_Y[i][1];
}
}
MPT_FORCEINLINE void End(VAR_13 &VAR_25)
{
for(int i = 0; i < Traits::numChannelsIn; i++)
{
VAR_25.nFilter_Y[i][0] = fy[i][0];
VAR_25.nFilter_Y[i][1] = fy[i][1];
}
}
// Filter values are clipped to double the input range
#define FUNC_3(VAR_5) Clamp(x, static_cast<Traits::output_t>(-2.0f), static_cast<Traits::output_t>(2.0f))
MPT_FORCEINLINE void operator() (typename Traits::VAR_15 &VAR_16, const CLASS_0 &VAR_25)
{
static_assert(VAR_6<VAR_0>(Traits::numChannelsIn) <= VAR_6<VAR_0>(Traits::VAR_19), "Too many input channels");
for(int i = 0; i < Traits::numChannelsIn; i++)
{
typename Traits::VAR_4 val = VAR_16[i] * VAR_25.nFilter_A0 + FUNC_3(fy[i][0]) * VAR_25.VAR_41 + FUNC_3(fy[i][1]) * VAR_25.VAR_42;
fy[i][1] = fy[i][0];
fy[i][0] = val - (VAR_16[i] * VAR_25.VAR_43);
VAR_16[i] = val;
}
}
#undef ClipFilter
};
OPENMPT_NAMESPACE_END
| 0.392901 | {'IMPORT_0': 'MixerInterface.h', 'VAR_0': 'int', 'VAR_1': 'out', 'VAR_2': 'IntToFloatTraits', 'VAR_3': 'std', 'VAR_4': 'output_t', 'FUNC_0': 'Convert', 'VAR_5': 'x', 'ID_0': 'x', 'VAR_6': 'static_cast', 'VAR_7': 'Int8MToFloatS', 'VAR_8': 'int16', 'VAR_9': 'Int16MToFloatS', 'VAR_10': 'Int8SToFloatS', 'VAR_11': 'Int16SToFloatS', 'FUNC_1': 'Start', 'VAR_12': 'Start', 'CLASS_0': 'ModChannel', 'VAR_13': 'ModChannel', 'CLASS_1': 'CResampler', 'VAR_14': 'CResampler', 'VAR_15': 'outbuf_t', 'VAR_16': 'outSample', 'VAR_17': 'inBuffer', 'VAR_18': 'posLo', 'VAR_19': 'numChannelsOut', 'VAR_20': 'fract', 'VAR_21': 'srcVol', 'VAR_22': 'lut', 'VAR_23': 'FastSincTablef', 'VAR_24': 'sinc', 'VAR_25': 'chn', 'FUNC_2': 'SamplePosition', 'VAR_26': 'gDownsample2x', 'VAR_27': 'SINC_PHASES_BITS', 'VAR_28': 'SINC_MASK', 'VAR_29': 'FIRFilterInterpolation', 'VAR_30': 'WFIRlut', 'VAR_31': 'WFIR_FRACMASK', 'VAR_32': 'lVol', 'VAR_33': 'rightVol', 'VAR_34': 'rRamp', 'CLASS_2': 'rRamp', 'VAR_35': 'rampRightVol', 'VAR_36': 'VOLUMERAMPPRECISION', 'VAR_37': 'outBuffer', 'VAR_38': 'MixMonoNoRamp', 'VAR_39': 'leftRamp', 'VAR_40': 'rightRamp', 'FUNC_3': 'ClipFilter', 'VAR_41': 'nFilter_B0', 'VAR_42': 'nFilter_B1', 'VAR_43': 'nFilter_HP'} |
/*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2004-2008 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
Copyright (C) 2013-2013 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
License as published by the Free Software Foundation and included
in the file LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
/*
* Properties we use for getting and setting ACLs.
*/
#ifndef __ACL_H
#define __ACL_H
/*
* * Number of acl errors to report per job.
* */
#define ACL_REPORT_ERR_MAX_PER_JOB 25
/*
* * Return codes from acl subroutines.
* */
typedef enum {
bacl_exit_fatal = -1,
bacl_exit_error = 0,
bacl_exit_ok = 1
} bacl_exit_code;
/* For shorter ACL strings when possible, define BACL_WANT_SHORT_ACLS */
/* #define BACL_WANT_SHORT_ACLS */
/* For numeric user/group ids when possible, define BACL_WANT_NUMERIC_IDS */
/* #define BACL_WANT_NUMERIC_IDS */
/*
* We support the following types of ACLs
*/
typedef enum {
BACL_TYPE_NONE = 0,
BACL_TYPE_ACCESS = 1,
BACL_TYPE_DEFAULT = 2,
BACL_TYPE_DEFAULT_DIR = 3,
BACL_TYPE_EXTENDED = 4,
BACL_TYPE_NFS4 = 5
} bacl_type;
/*
* This value is used as ostype when we encounter an invalid acl type.
* The way the code is build this should never happen.
*/
#if !defined(ACL_TYPE_NONE)
#define ACL_TYPE_NONE 0x0
#endif
#if defined(HAVE_FREEBSD_OS) || \
defined(HAVE_DARWIN_OS) || \
defined(HAVE_HPUX_OS) || \
defined(HAVE_LINUX_OS)
#define BACL_ENOTSUP EOPNOTSUPP
#elif defined(HAVE_IRIX_OS)
#define BACL_ENOTSUP ENOSYS
#endif
#define BACL_FLAG_SAVE_NATIVE 0x01
#define BACL_FLAG_SAVE_AFS 0x02
#define BACL_FLAG_RESTORE_NATIVE 0x04
#define BACL_FLAG_RESTORE_AFS 0x08
struct acl_build_data_t {
uint32_t nr_errors;
uint32_t content_length;
POOLMEM *content;
};
struct acl_parse_data_t {
uint32_t nr_errors;
};
/*
* Internal tracking data.
*/
struct acl_data_t {
int filetype;
POOLMEM *last_fname;
uint32_t flags; /* See BACL_FLAG_* */
uint32_t current_dev;
union {
struct acl_build_data_t *build;
struct acl_parse_data_t *parse;
} u;
};
#endif
| /*
BAREOS® - Backup Archiving REcovery Open Sourced
Copyright (C) 2004-2008 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
Copyright (C) 2013-2013 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
License as published by the Free Software Foundation and included
in the file LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
/*
* Properties we use for getting and setting ACLs.
*/
#ifndef VAR_0
#define VAR_0
/*
* * Number of acl errors to report per job.
* */
#define VAR_1 25
/*
* * Return codes from acl subroutines.
* */
typedef enum {
VAR_2 = -1,
VAR_3 = 0,
VAR_4 = 1
} bacl_exit_code;
/* For shorter ACL strings when possible, define BACL_WANT_SHORT_ACLS */
/* #define BACL_WANT_SHORT_ACLS */
/* For numeric user/group ids when possible, define BACL_WANT_NUMERIC_IDS */
/* #define BACL_WANT_NUMERIC_IDS */
/*
* We support the following types of ACLs
*/
typedef enum {
VAR_5 = 0,
BACL_TYPE_ACCESS = 1,
BACL_TYPE_DEFAULT = 2,
BACL_TYPE_DEFAULT_DIR = 3,
BACL_TYPE_EXTENDED = 4,
BACL_TYPE_NFS4 = 5
} ID_0;
/*
* This value is used as ostype when we encounter an invalid acl type.
* The way the code is build this should never happen.
*/
#if !defined(VAR_6)
#define VAR_6 0x0
#endif
#if defined(HAVE_FREEBSD_OS) || \
defined(HAVE_DARWIN_OS) || \
defined(VAR_7) || \
defined(VAR_8)
#define VAR_9 EOPNOTSUPP
#elif defined(VAR_10)
#define VAR_9 ENOSYS
#endif
#define BACL_FLAG_SAVE_NATIVE 0x01
#define BACL_FLAG_SAVE_AFS 0x02
#define VAR_11 0x04
#define BACL_FLAG_RESTORE_AFS 0x08
struct acl_build_data_t {
uint32_t nr_errors;
uint32_t content_length;
CLASS_0 *VAR_12;
};
struct CLASS_1 {
uint32_t nr_errors;
};
/*
* Internal tracking data.
*/
struct CLASS_2 {
int VAR_13;
CLASS_0 *last_fname;
uint32_t flags; /* See BACL_FLAG_* */
uint32_t current_dev;
union {
struct acl_build_data_t *VAR_14;
struct CLASS_1 *parse;
} VAR_15;
};
#endif
| 0.638155 | {'VAR_0': '__ACL_H', 'VAR_1': 'ACL_REPORT_ERR_MAX_PER_JOB', 'VAR_2': 'bacl_exit_fatal', 'VAR_3': 'bacl_exit_error', 'VAR_4': 'bacl_exit_ok', 'VAR_5': 'BACL_TYPE_NONE', 'ID_0': 'bacl_type', 'VAR_6': 'ACL_TYPE_NONE', 'VAR_7': 'HAVE_HPUX_OS', 'VAR_8': 'HAVE_LINUX_OS', 'VAR_9': 'BACL_ENOTSUP', 'VAR_10': 'HAVE_IRIX_OS', 'VAR_11': 'BACL_FLAG_RESTORE_NATIVE', 'CLASS_0': 'POOLMEM', 'VAR_12': 'content', 'CLASS_1': 'acl_parse_data_t', 'CLASS_2': 'acl_data_t', 'VAR_13': 'filetype', 'VAR_14': 'build', 'VAR_15': 'u'} |
/* abounce_event - resume pseudo thread after server reply event */
static void abounce_event(int event, void *context)
{
ABOUNCE *ap = (ABOUNCE *) context;
int status;
ABOUNCE_EVENT_DISABLE(vstream_fileno(ap->fp), abounce_event, context);
abounce_done(ap, (event != EVENT_TIME
&& attr_scan(ap->fp, ATTR_FLAG_STRICT,
RECV_ATTR_INT(MAIL_ATTR_STATUS, &status),
ATTR_TYPE_END) == 1) ? status : -1);
} | /* abounce_event - resume pseudo thread after server reply event */
static void FUNC_0(int event, void *VAR_1)
{
CLASS_0 *VAR_2 = (CLASS_0 *) VAR_1;
int VAR_3;
FUNC_1(FUNC_2(VAR_2->VAR_4), VAR_0, VAR_1);
FUNC_3(VAR_2, (event != EVENT_TIME
&& FUNC_4(VAR_2->VAR_4, VAR_5,
RECV_ATTR_INT(MAIL_ATTR_STATUS, &VAR_3),
VAR_6) == 1) ? VAR_3 : -1);
} | 0.805549 | {'FUNC_0': 'abounce_event', 'VAR_0': 'abounce_event', 'VAR_1': 'context', 'CLASS_0': 'ABOUNCE', 'VAR_2': 'ap', 'VAR_3': 'status', 'FUNC_1': 'ABOUNCE_EVENT_DISABLE', 'FUNC_2': 'vstream_fileno', 'VAR_4': 'fp', 'FUNC_3': 'abounce_done', 'FUNC_4': 'attr_scan', 'VAR_5': 'ATTR_FLAG_STRICT', 'VAR_6': 'ATTR_TYPE_END'} |
//**************************************************************************************************
//
// OSSIM Open Source Geospatial Data Processing Library
// See top level LICENSE.txt file for license information
//
//**************************************************************************************************
#ifndef ossimPotraceToolFactory_HEADER
#define ossimPotraceToolFactory_HEADER 1
#include <ossim/plugin/ossimPluginConstants.h>
#include <ossim/util/ossimToolFactoryBase.h>
#include <potrace/src/ossimPotraceTool.h>
class ossimString;
class ossimFilename;
class ossimKeywordlist;
class OSSIM_PLUGINS_DLL ossimPotraceToolFactory: public ossimToolFactoryBase
{
public:
static ossimPotraceToolFactory* instance();
virtual ~ossimPotraceToolFactory();
virtual ossimTool* createTool(const std::string& typeName) const;
virtual void getTypeNameList(std::vector<ossimString>& typeList) const;
virtual void getCapabilities(std::map<std::string, std::string>& capabilities) const;
virtual std::map<std::string, std::string> getCapabilities() const;
protected:
ossimPotraceToolFactory();
ossimPotraceToolFactory(const ossimPotraceToolFactory&);
void operator=(const ossimPotraceToolFactory&);
/** static instance of this class */
static ossimPotraceToolFactory* s_instance;
};
#endif /* end of #ifndef ossimPotraceToolFactory_HEADER */
| //**************************************************************************************************
//
// OSSIM Open Source Geospatial Data Processing Library
// See top level LICENSE.txt file for license information
//
//**************************************************************************************************
#ifndef ossimPotraceToolFactory_HEADER
#define ossimPotraceToolFactory_HEADER 1
#include <ossim/plugin/ossimPluginConstants.h>
#include <ossim/util/ossimToolFactoryBase.h>
#include <potrace/src/ossimPotraceTool.h>
class ossimString;
class ossimFilename;
class ossimKeywordlist;
class VAR_0 ossimPotraceToolFactory: public ossimToolFactoryBase
{
public:
static ossimPotraceToolFactory* instance();
virtual ~ossimPotraceToolFactory();
virtual ossimTool* createTool(const CLASS_0::string& typeName) const;
virtual void getTypeNameList(CLASS_0::vector<ossimString>& typeList) const;
virtual void getCapabilities(CLASS_0::VAR_2<VAR_1::string, CLASS_0::string>& capabilities) const;
virtual VAR_1::VAR_2<VAR_1::string, VAR_1::string> getCapabilities() const;
protected:
ossimPotraceToolFactory();
ossimPotraceToolFactory(const ossimPotraceToolFactory&);
void operator=(const ossimPotraceToolFactory&);
/** static instance of this class */
static ossimPotraceToolFactory* VAR_3;
};
#endif /* end of #ifndef ossimPotraceToolFactory_HEADER */
| 0.120198 | {'VAR_0': 'OSSIM_PLUGINS_DLL', 'CLASS_0': 'std', 'VAR_1': 'std', 'VAR_2': 'map', 'VAR_3': 's_instance'} |
#ifndef _PYRUNTIME_H
#define _PYRUNTIME_H
/*
* Fledge Python Runtime.
*
* Copyright (c) 2021 Dianomic Systems
*
* Released under the Apache 2.0 Licence
*
* Author: <NAME>
*/
#include <Python.h>
class PythonRuntime {
public:
static PythonRuntime *getPythonRuntime();
void execute(const std::string& python);
PyObject *call(const std::string& name, const std::string& fmt, ...);
PyObject *call(PyObject *module, const std::string& name, const std::string& fmt, ...);
PyObject *importModule(const std::string& name);
private:
PythonRuntime();
PythonRuntime(const PythonRuntime& rhs);
PythonRuntime& operator=(const PythonRuntime& rhs);
void logException(const std::string& name);
static PythonRuntime *m_instance;
};
#endif
| #ifndef _PYRUNTIME_H
#define _PYRUNTIME_H
/*
* Fledge Python Runtime.
*
* Copyright (c) 2021 Dianomic Systems
*
* Released under the Apache 2.0 Licence
*
* Author: <NAME>
*/
#include <Python.h>
class PythonRuntime {
public:
VAR_0 PythonRuntime *FUNC_0();
void FUNC_1(const CLASS_0::string& VAR_1);
CLASS_1 *call(const CLASS_0::string& VAR_2, const CLASS_0::string& VAR_3, ...);
CLASS_1 *call(CLASS_1 *module, const CLASS_0::string& VAR_2, const CLASS_0::string& VAR_3, ...);
CLASS_1 *FUNC_2(const CLASS_0::string& VAR_2);
private:
PythonRuntime();
PythonRuntime(const PythonRuntime& VAR_4);
PythonRuntime& VAR_5=(const PythonRuntime& VAR_4);
void FUNC_3(const CLASS_0::string& VAR_2);
static PythonRuntime *m_instance;
};
#endif
| 0.578775 | {'VAR_0': 'static', 'FUNC_0': 'getPythonRuntime', 'FUNC_1': 'execute', 'CLASS_0': 'std', 'VAR_1': 'python', 'CLASS_1': 'PyObject', 'VAR_2': 'name', 'VAR_3': 'fmt', 'FUNC_2': 'importModule', 'VAR_4': 'rhs', 'VAR_5': 'operator', 'FUNC_3': 'logException'} |
#ifndef __IVORY_FREERTOS_SEMAPHORE_WRAPPER_H__
#define __IVORY_FREERTOS_SEMAPHORE_WRAPPER_H__
#include "FreeRTOS.h"
#include "semphr.h"
struct binary_semaphore {
SemaphoreHandle_t v;
};
void ivory_freertos_binary_semaphore_create(struct binary_semaphore* bs_handle);
void ivory_freertos_binary_semaphore_takeblocking(struct binary_semaphore* bs_handle);
void ivory_freertos_binary_semaphore_give(struct binary_semaphore* bs_handle);
void ivory_freertos_binary_semaphore_give_from_isr(struct binary_semaphore* bs_handle);
#endif // __IVORY_FREERTOS_SEMAPHORE_WRAPPER_H__
|
#ifndef VAR_0
#define VAR_0
#include "IMPORT_0"
#include "IMPORT_1"
struct CLASS_0 {
CLASS_1 VAR_1;
};
void FUNC_0(struct CLASS_0* VAR_2);
void FUNC_1(struct CLASS_0* VAR_2);
void FUNC_2(struct CLASS_0* VAR_2);
void FUNC_3(struct CLASS_0* VAR_2);
#endif // __IVORY_FREERTOS_SEMAPHORE_WRAPPER_H__
| 0.879603 | {'VAR_0': '__IVORY_FREERTOS_SEMAPHORE_WRAPPER_H__', 'IMPORT_0': 'FreeRTOS.h', 'IMPORT_1': 'semphr.h', 'CLASS_0': 'binary_semaphore', 'CLASS_1': 'SemaphoreHandle_t', 'VAR_1': 'v', 'FUNC_0': 'ivory_freertos_binary_semaphore_create', 'VAR_2': 'bs_handle', 'FUNC_1': 'ivory_freertos_binary_semaphore_takeblocking', 'FUNC_2': 'ivory_freertos_binary_semaphore_give', 'FUNC_3': 'ivory_freertos_binary_semaphore_give_from_isr'} |
#include "libm.h"
//FIXME
long double complex csinhl(long double complex z)
{
return csinh(z);
}
| #include "IMPORT_0"
//FIXME
long double VAR_0 FUNC_0(long double VAR_0 VAR_1)
{
return FUNC_1(VAR_1);
}
| 0.914432 | {'IMPORT_0': 'libm.h', 'VAR_0': 'complex', 'FUNC_0': 'csinhl', 'VAR_1': 'z', 'FUNC_1': 'csinh'} |
//
// PaintingliteUUID.h
// Paintinglite
//
// Created by <NAME> on 2020/6/10.
// Copyright © 2020 <NAME>. All rights reserved.
//
/*!
@header PaintingliteUUID
@abstract PaintingliteUUID 提供SDK框架中生成随机UUID
@author CreaterOS
@version 1.00 2020/6/10 Creation (此文档的版本信息)
*/
#import "PaintingliteCUDOptions.h"
NS_ASSUME_NONNULL_BEGIN
/*!
@class PaintingliteUUID
@abstract PaintingliteUUID 提供SDK框架中生成随机UUID
*/
@interface PaintingliteUUID : PaintingliteCUDOptions
/*!
@method getPaintingliteUUID
@abstract 获得UUID
@discussion 获得UUID
@result NSString
*/
+ (NSString *__nonnull)getPaintingliteUUID;
@end
NS_ASSUME_NONNULL_END
| //
// PaintingliteUUID.h
// Paintinglite
//
// Created by <NAME> on 2020/6/10.
// Copyright © 2020 <NAME>. All rights reserved.
//
/*!
@header PaintingliteUUID
@abstract PaintingliteUUID 提供SDK框架中生成随机UUID
@author CreaterOS
@version 1.00 2020/6/10 Creation (此文档的版本信息)
*/
#import "PaintingliteCUDOptions.h"
CLASS_0
/*!
@class PaintingliteUUID
@abstract PaintingliteUUID 提供SDK框架中生成随机UUID
*/
@VAR_0 PaintingliteUUID : VAR_1
/*!
@method getPaintingliteUUID
@abstract 获得UUID
@discussion 获得UUID
@result NSString
*/
+ (VAR_2 *__nonnull)VAR_3;
@CLASS_1
VAR_4
| 0.651658 | {'CLASS_0': 'NS_ASSUME_NONNULL_BEGIN', 'VAR_0': 'interface', 'VAR_1': 'PaintingliteCUDOptions', 'VAR_2': 'NSString', 'VAR_3': 'getPaintingliteUUID', 'CLASS_1': 'end', 'VAR_4': 'NS_ASSUME_NONNULL_END'} |
//Copyright (c) 2013 <NAME>(meson800)
//The MIT License - See ../../../LICENSE for more info
#ifndef HOOK_OBSERVER
#define HOOK_OBSERVER
#include "PanelClickRecorderOutput.h"
class PanelClickRecorderOutput;
extern class HookObserver
{
public:
HookObserver() {}
void h_handlePanelMouseEvent(int id, int ev, int mx, int my);
void setUpReciever(PanelClickRecorderOutput * _callbackClass);
private:
PanelClickRecorderOutput * callbackClass;
} observer;
#endif | //Copyright (c) 2013 <NAME>(meson800)
//The MIT License - See ../../../LICENSE for more info
#ifndef HOOK_OBSERVER
#define HOOK_OBSERVER
#include "IMPORT_0"
class PanelClickRecorderOutput;
extern class HookObserver
{
public:
HookObserver() {}
void h_handlePanelMouseEvent(int VAR_0, int ev, int mx, int my);
void setUpReciever(PanelClickRecorderOutput * _callbackClass);
private:
PanelClickRecorderOutput * callbackClass;
} observer;
#endif | 0.188027 | {'IMPORT_0': 'PanelClickRecorderOutput.h', 'VAR_0': 'id'} |
#include "stdafx.h"
#ifndef STATBAR_H_INCLUDED
#define STATBAR_H_INCLUDED
#include "UIStructs.h"
namespace StatBar {
war3::CStatBar* create(void* parent = 0, war3::CUnit* owner = 0, uint32_t type = 0);
war3::CStatBar* init(war3::CStatBar* t, void* parent = 0, war3::CUnit* owner = 0, uint32_t type = 0);
void destroy(war3::CStatBar* t);
uint32_t setOwner(war3::CStatBar* t, war3::CUnit* unit);
uint32_t update(war3::CStatBar* t);
}
#endif | #include "stdafx.h"
#ifndef VAR_0
#define VAR_0
#include "UIStructs.h"
namespace StatBar {
war3::CStatBar* create(void* parent = 0, war3::VAR_1* owner = 0, VAR_2 type = 0);
war3::CStatBar* init(war3::CStatBar* t, void* parent = 0, war3::VAR_1* owner = 0, VAR_2 type = 0);
void destroy(war3::CStatBar* t);
uint32_t setOwner(war3::CStatBar* t, war3::VAR_1* unit);
uint32_t update(war3::CStatBar* t);
}
#endif | 0.093148 | {'VAR_0': 'STATBAR_H_INCLUDED', 'VAR_1': 'CUnit', 'VAR_2': 'uint32_t'} |
#include<stdio.h>
#include<math.h>
int main()
{
int i,k,c,br=0,new=0,mark=0;
float masiv1[1000],masiv2[64],sum;
for(i=0;scanf("%f",&masiv1[i])!=EOF;i++);
masiv2[0]=masiv1[0];
for(k=1;k<i;k++)
{
if(k==1)br++;
for(c=0;c<k;c++)
{
if(masiv1[k]==masiv1[c]){mark=1;break;}
}
if(mark==1){mark=0;continue;}
br++;
if(br>=64)break;
new++;
masiv2[new]=masiv1[k];
}
sum=0;
for(new=0;new<br;new++){sum=sum+fmod(masiv2[new],br);}
printf("%d\n%.3f",br,sum);
return 0;
}
| #include<stdio.h>
#include<math.h>
int FUNC_0()
{
int VAR_0,k,c,br=0,new=0,VAR_1=0;
float VAR_2[1000],masiv2[64],VAR_3;
for(VAR_0=0;scanf("%f",&VAR_2[VAR_0])!=VAR_4;VAR_0++);
masiv2[0]=VAR_2[0];
for(k=1;k<VAR_0;k++)
{
if(k==1)br++;
for(c=0;c<k;c++)
{
if(VAR_2[k]==VAR_2[c]){VAR_1=1;break;}
}
if(VAR_1==1){VAR_1=0;continue;}
br++;
if(br>=64)break;
new++;
masiv2[new]=VAR_2[k];
}
VAR_3=0;
for(new=0;new<br;new++){VAR_3=VAR_3+fmod(masiv2[new],br);}
FUNC_1("%d\n%.3f",br,VAR_3);
return 0;
}
| 0.510137 | {'FUNC_0': 'main', 'VAR_0': 'i', 'VAR_1': 'mark', 'VAR_2': 'masiv1', 'VAR_3': 'sum', 'VAR_4': 'EOF', 'FUNC_1': 'printf'} |
/**
* @brief User defined output funciton
* @param jd: pointer to JDEC structure.
* bitmap: pointer to the buffer of decompressed RGB data
* rect: the rectanglar range of decompressed area
* @retval 1
*/
UINT JpgDec_out_func(JDEC* jd, void* bitmap, JRECT* rect)
{
IODEV *dev = (IODEV*)jd->device;
BYTE *src, *dst;
UINT y, bws, bwd;
if (rect->left == 0) {
}
RgbLcdShowBitmap(rect->left,
rect->top,
rect->right - rect->left + 1,
rect->bottom - rect->top + 1,
(u16*)bitmap);
return 1;
} | /**
* @brief User defined output funciton
* @param jd: pointer to JDEC structure.
* bitmap: pointer to the buffer of decompressed RGB data
* rect: the rectanglar range of decompressed area
* @retval 1
*/
UINT FUNC_0(CLASS_0* jd, void* bitmap, CLASS_1* VAR_0)
{
CLASS_2 *dev = (CLASS_2*)jd->VAR_1;
CLASS_3 *VAR_2, *VAR_3;
UINT VAR_4, VAR_5, VAR_6;
if (VAR_0->VAR_7 == 0) {
}
FUNC_1(VAR_0->VAR_7,
VAR_0->top,
VAR_0->right - VAR_0->VAR_7 + 1,
VAR_0->VAR_8 - VAR_0->top + 1,
(u16*)bitmap);
return 1;
} | 0.875299 | {'FUNC_0': 'JpgDec_out_func', 'CLASS_0': 'JDEC', 'CLASS_1': 'JRECT', 'VAR_0': 'rect', 'CLASS_2': 'IODEV', 'VAR_1': 'device', 'CLASS_3': 'BYTE', 'VAR_2': 'src', 'VAR_3': 'dst', 'VAR_4': 'y', 'VAR_5': 'bws', 'VAR_6': 'bwd', 'VAR_7': 'left', 'FUNC_1': 'RgbLcdShowBitmap', 'VAR_8': 'bottom'} |
#include <stdio.h>
int main()
{
int n, a[20], b[20], bb[20], i, j, time, flag = 0, lowest;
int g[20] = {0}, tat[20], wt[20], d;
float stat = 0, swt = 0;
printf("Enter the no. of processes:\n");
scanf("%d", &n);
printf("Enter the arrival time and burst time:\n");
for(i=0; i<n; i++)
{
scanf("%d %d", &a[i], &bb[i]);
}
for(i=0;i<n;i++)
b[i] = bb[i];
g[0] = a[0];
g[1] = b[0];
time = g[1];
for(i=1;i<n;i++)
{
if(a[i] <= time)
{
lowest = 999;
if(time >= a[n])
d = n;
else
d = time + 1;
for(j=1;j<d;j++)
{
if(lowest >= b[j])
{
lowest = b[j];
flag = j;
}
}
time += lowest;
b[flag] = 999;
g[i+1] = time;
}
}
for(i=0;i<=n;i++)
printf("%d\t", g[i]);
for(i=0;i<n;i++)
{
tat[i] = g[i+1] - a[i];
wt[i] = tat[i] - bb[i];
stat += tat[i];
swt += wt[i];
}
printf("\n");
for(i=0;i<n;i++)
printf("%d\t", tat[i]);
printf("\n");
for(i=0;i<n;i++)
printf("%d\t", wt[i]);
printf("Avg tat = %f\n", stat/n);
printf("Avg wt = %f\n", swt/n);
printf("\n");
return 0;
} | #include <stdio.h>
int main()
{
int n, a[20], b[20], bb[20], i, j, time, flag = 0, lowest;
int g[20] = {0}, tat[20], wt[20], d;
float stat = 0, VAR_0 = 0;
printf("Enter the no. of processes:\n");
scanf("%d", &n);
printf("Enter the arrival time and burst time:\n");
for(i=0; i<n; i++)
{
scanf("%d %d", &a[i], &bb[i]);
}
for(i=0;i<n;i++)
b[i] = bb[i];
g[0] = a[0];
g[1] = b[0];
time = g[1];
for(i=1;i<n;i++)
{
if(a[i] <= time)
{
lowest = 999;
if(time >= a[n])
d = n;
else
d = time + 1;
for(j=1;j<d;j++)
{
if(lowest >= b[j])
{
lowest = b[j];
flag = j;
}
}
time += lowest;
b[flag] = 999;
g[i+1] = time;
}
}
for(i=0;i<=n;i++)
printf("%d\t", g[i]);
for(i=0;i<n;i++)
{
tat[i] = g[i+1] - a[i];
wt[i] = tat[i] - bb[i];
stat += tat[i];
VAR_0 += wt[i];
}
printf("\n");
for(i=0;i<n;i++)
printf("%d\t", tat[i]);
printf("\n");
for(i=0;i<n;i++)
printf("%d\t", wt[i]);
printf("Avg tat = %f\n", stat/n);
printf("Avg wt = %f\n", VAR_0/n);
printf("\n");
return 0;
} | 0.143386 | {'VAR_0': 'swt'} |
//
// sell_order.h
// Laboratory 3
//
// Created by <NAME> on 2020-11-16.
//
#ifndef sell_order_h
#define sell_order_h
#include<string>
class orders
{
public:
std::string name__;
int price__;
orders* next__;
orders() {}
orders(std::string name_, int price_): name__(name_), price__(price_) {}
//orders(std::string name, int price): name__(name), price__(price) {}
};
#endif /* sell_order_h */
| //
// sell_order.h
// Laboratory 3
//
// Created by <NAME> on 2020-11-16.
//
#ifndef VAR_0
#define VAR_0
#include<string>
class orders
{
public:
std::string name__;
int price__;
orders* VAR_1;
orders() {}
orders(ID_0::string name_, int VAR_2): name__(name_), price__(VAR_2) {}
//orders(std::string name, int price): name__(name), price__(price) {}
};
#endif /* sell_order_h */
| 0.25047 | {'VAR_0': 'sell_order_h', 'ID_0': 'std', 'VAR_1': 'next__', 'VAR_2': 'price_'} |
/*******************************************************************************/
/* This file is auto-generated by Azure RTOS GUIX Studio. Do not edit this */
/* file by hand. Modifications to this file should only be made by running */
/* the Azure RTOS GUIX Studio application and re-generating the application */
/* specification file(s). For more information please refer to the Azure RTOS */
/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */
/* */
/* GUIX Studio Revision 6.1.7.0 */
/* Date (dd.mm.yyyy): 29. 6.2021 Time (hh:mm): 21:48 */
/*******************************************************************************/
#define GUIX_STUDIO_GENERATED_FILE
#include <stddef.h>
#include "h750_180_90_resources.h"
#include "h750_180_90_specifications.h"
static GX_WIDGET *gx_studio_nested_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent);
WINDOW_CONTROL_BLOCK window;
GX_DISPLAY main_display_control_block;
GX_WINDOW_ROOT main_display_root_window;
GX_CANVAS main_display_canvas_control_block;
extern GX_CONST GX_THEME *main_display_theme_table[];
extern GX_CONST GX_STRING *main_display_language_table[];
GX_STUDIO_DISPLAY_INFO h750_180_90_display_table[1] =
{
{
"main_display",
"main_display_canvas",
main_display_theme_table,
main_display_language_table,
MAIN_DISPLAY_THEME_TABLE_SIZE,
MAIN_DISPLAY_LANGUAGE_TABLE_SIZE,
MAIN_DISPLAY_STRING_TABLE_SIZE,
160, /* x resolution */
80, /* y resolution */
&main_display_control_block,
&main_display_canvas_control_block,
&main_display_root_window,
GX_NULL, /* canvas memory area */
25600, /* canvas memory size in bytes */
GX_SCREEN_ROTATION_NONE /* rotation angle */
}
};
UINT gx_studio_prompt_create(GX_CONST GX_STUDIO_WIDGET *info, GX_WIDGET *control_block, GX_WIDGET *parent)
{
UINT status;
GX_PROMPT *prompt = (GX_PROMPT *) control_block;
GX_PROMPT_PROPERTIES *props = (GX_PROMPT_PROPERTIES *) info->properties;
status = gx_prompt_create(prompt, info->widget_name, parent, props->string_id, info->style, info->widget_id, &info->size);
if (status == GX_SUCCESS)
{
gx_prompt_font_set(prompt, props->font_id);
#if defined(GUIX_5_4_0_COMPATIBILITY)
gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id);
#else
gx_prompt_text_color_set(prompt, props->normal_text_color_id, props->selected_text_color_id, props->disabled_text_color_id);
#endif
}
return status;
}
UINT gx_studio_window_create(GX_CONST GX_STUDIO_WIDGET *info, GX_WIDGET *control_block, GX_WIDGET *parent)
{
UINT status;
GX_WINDOW *window = (GX_WINDOW *) control_block;
GX_WINDOW_PROPERTIES *props = (GX_WINDOW_PROPERTIES *) info->properties;
status = gx_window_create(window, info->widget_name, parent, info->style, info->widget_id, &info->size);
if (status == GX_SUCCESS)
{
if (props->wallpaper_id)
{
gx_window_wallpaper_set(window, props->wallpaper_id, info->style & GX_STYLE_TILE_WALLPAPER);
}
}
return status;
}
GX_WINDOW_PROPERTIES window_properties =
{
0 /* wallpaper pixelmap id */
};
GX_PROMPT_PROPERTIES window_prompt_properties =
{
GX_STRING_ID_STRING_3, /* string id */
GX_FONT_ID_PROMPT, /* font id */
GX_COLOR_ID_TEXT, /* normal text color */
GX_COLOR_ID_SELECTED_TEXT, /* selected text color */
GX_COLOR_ID_DISABLED_TEXT /* disabled text color */
};
GX_CONST GX_STUDIO_WIDGET window_prompt_define =
{
"prompt",
GX_TYPE_PROMPT, /* widget type */
GX_ID_NONE, /* widget id */
#if defined(GX_WIDGET_USER_DATA)
0, /* user data */
#endif
GX_STYLE_BORDER_THIN|GX_STYLE_ENABLED|GX_STYLE_TEXT_CENTER, /* style flags */
GX_STATUS_ACCEPTS_FOCUS, /* status flags */
sizeof(GX_PROMPT), /* control block size */
GX_COLOR_ID_WIDGET_FILL, /* normal color id */
GX_COLOR_ID_SELECTED_FILL, /* selected color id */
GX_COLOR_ID_DISABLED_FILL, /* disabled color id */
gx_studio_prompt_create, /* create function */
GX_NULL, /* drawing function override */
GX_NULL, /* event function override */
{21, 22, 100, 45}, /* widget size */
GX_NULL, /* no next widget */
GX_NULL, /* no child widgets */
offsetof(WINDOW_CONTROL_BLOCK, window_prompt), /* control block */
(void *) &window_prompt_properties /* extended properties */
};
GX_CONST GX_STUDIO_WIDGET window_define =
{
"window",
GX_TYPE_WINDOW, /* widget type */
GX_ID_NONE, /* widget id */
#if defined(GX_WIDGET_USER_DATA)
0, /* user data */
#endif
GX_STYLE_BORDER_THIN|GX_STYLE_ENABLED, /* style flags */
GX_STATUS_ACCEPTS_FOCUS, /* status flags */
sizeof(WINDOW_CONTROL_BLOCK), /* control block size */
GX_COLOR_ID_WINDOW_FILL, /* normal color id */
GX_COLOR_ID_WINDOW_FILL, /* selected color id */
GX_COLOR_ID_DISABLED_FILL, /* disabled color id */
gx_studio_window_create, /* create function */
GX_NULL, /* drawing function override */
GX_NULL, /* event function override */
{0, 0, 179, 89}, /* widget size */
GX_NULL, /* next widget */
&window_prompt_define, /* child widget */
0, /* control block */
(void *) &window_properties /* extended properties */
};
GX_CONST GX_STUDIO_WIDGET_ENTRY h750_180_90_widget_table[] =
{
{ &window_define, (GX_WIDGET *) &window },
{GX_NULL, GX_NULL}
};
static GX_WIDGET *gx_studio_nested_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)
{
UINT status = GX_SUCCESS;
GX_WIDGET *widget = GX_NULL;
GX_VALUE list_count = 0;
GX_VALUE list_total_count = 0;
if(parent && (parent->gx_widget_type == GX_TYPE_MENU))
{
list_total_count = ((GX_MENU *)parent)->gx_menu_list_total_count;
}
while(definition && status == GX_SUCCESS)
{
if (definition->create_function)
{
if (definition->style & GX_STYLE_DYNAMICALLY_ALLOCATED)
{
status = gx_widget_allocate(&widget, definition->control_block_size);
if (status != GX_SUCCESS)
{
return GX_NULL;
}
}
else
{
if (control == GX_NULL)
{
return GX_NULL;
}
widget = (GX_WIDGET *) (control + definition->control_block_offset);
}
status = definition->create_function(definition, widget, parent);
if(list_count < list_total_count)
{
gx_menu_insert((GX_MENU *)parent, widget);
((GX_MENU *)parent)->gx_menu_list_total_count--;
list_count++;
}
if (status == GX_SUCCESS)
{
if (definition->widget_type != GX_TYPE_TEMPLATE)
{
#if defined(GUIX_5_4_0_COMPATIBILITY)
gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id);
#else
gx_widget_fill_color_set(widget, definition->normal_fill_color_id, definition->selected_fill_color_id, definition->disabled_fill_color_id);
#endif
}
if (!(definition->status & GX_STATUS_ACCEPTS_FOCUS))
{
gx_widget_status_remove(widget, GX_STATUS_ACCEPTS_FOCUS);
}
if (definition->draw_function)
{
gx_widget_draw_set(widget, definition->draw_function);
}
if (definition->event_function)
{
gx_widget_event_process_set(widget, definition->event_function);
}
#if defined(GX_WIDGET_USER_DATA)
widget->gx_widget_user_data = definition->user_data;
#endif
if (definition->child_widget)
{
gx_studio_nested_widget_create(control, definition->child_widget, widget);
}
}
definition = definition->next_widget;
}
}
return widget;
}
GX_WIDGET *gx_studio_widget_create(GX_BYTE *control, GX_CONST GX_STUDIO_WIDGET *definition, GX_WIDGET *parent)
{
GX_WIDGET *widget;
widget = gx_studio_nested_widget_create(control, definition, GX_NULL);
if (parent && widget)
{
gx_widget_attach(parent, widget);
}
return widget;
}
UINT gx_studio_named_widget_create(char *name, GX_WIDGET *parent, GX_WIDGET **new_widget)
{
UINT status = GX_FAILURE;
GX_CONST GX_STUDIO_WIDGET_ENTRY *entry = h750_180_90_widget_table;
GX_WIDGET *widget = GX_NULL;
while(entry->widget_information)
{
if (!strcmp(name, entry->widget_information->widget_name))
{
widget = gx_studio_widget_create((GX_BYTE *) entry->widget, entry->widget_information, parent);
if (widget)
{
status = GX_SUCCESS;
}
break;
}
entry++;
}
if (new_widget)
{
*new_widget = widget;
}
return status;
}
UINT gx_studio_display_configure(USHORT display, UINT (*driver)(GX_DISPLAY *),
GX_UBYTE language, USHORT theme, GX_WINDOW_ROOT **return_root)
{
GX_CONST GX_THEME *theme_ptr;
GX_RECTANGLE size;
GX_STUDIO_DISPLAY_INFO *display_info = &h750_180_90_display_table[display];
/* create the requested display */
gx_display_create(display_info->display,
display_info->name,
driver,
(GX_VALUE) display_info->x_resolution,
(GX_VALUE) display_info->y_resolution);
/* install the request theme */
if(display_info->theme_table)
{
theme_ptr = display_info->theme_table[theme];
if(theme_ptr)
{
gx_display_color_table_set(display_info->display, theme_ptr->theme_color_table, theme_ptr->theme_color_table_size);
/* install the color palette if required */
if (display_info->display->gx_display_driver_palette_set &&
theme_ptr->theme_palette != NULL)
{
display_info->display->gx_display_driver_palette_set(display_info->display, theme_ptr->theme_palette, theme_ptr->theme_palette_size);
}
gx_display_font_table_set(display_info->display, theme_ptr->theme_font_table, theme_ptr->theme_font_table_size);
gx_display_pixelmap_table_set(display_info->display, theme_ptr->theme_pixelmap_table, theme_ptr->theme_pixelmap_table_size);
gx_system_scroll_appearance_set(theme_ptr->theme_vertical_scroll_style, (GX_SCROLLBAR_APPEARANCE *) &theme_ptr->theme_vertical_scrollbar_appearance);
gx_system_scroll_appearance_set(theme_ptr->theme_horizontal_scroll_style, (GX_SCROLLBAR_APPEARANCE *) &theme_ptr->theme_horizontal_scrollbar_appearance);
gx_display_language_table_set_ext(display_info->display, display_info->language_table, (GX_UBYTE) display_info->language_table_size, display_info->string_table_size);
gx_display_active_language_set(display_info->display, language);
}
}
/* Set screen rotation angle. */
display_info->display->gx_display_rotation_angle = display_info->rotation_angle;
/* create the canvas for this display */
gx_canvas_create(display_info->canvas,
display_info->canvas_name,
display_info->display,
GX_CANVAS_MANAGED | GX_CANVAS_VISIBLE,
display_info->x_resolution,
display_info->y_resolution,
display_info->canvas_memory,
display_info->canvas_memory_size);
/* Create the root window for this canvas */
gx_utility_rectangle_define(&size,
0, 0,
(GX_VALUE) (display_info->x_resolution - 1),
(GX_VALUE) (display_info->y_resolution - 1));
gx_window_root_create(display_info->root_window,
display_info->name,
display_info->canvas, GX_STYLE_NONE, 0, &size);
if (return_root)
{
*return_root = display_info->root_window;
}
return GX_SUCCESS;
}
#undef GUIX_STUDIO_GENERATED_FILE
| /*******************************************************************************/
/* This file is auto-generated by Azure RTOS GUIX Studio. Do not edit this */
/* file by hand. Modifications to this file should only be made by running */
/* the Azure RTOS GUIX Studio application and re-generating the application */
/* specification file(s). For more information please refer to the Azure RTOS */
/* GUIX Studio User Guide, or visit our web site at azure.com/rtos */
/* */
/* GUIX Studio Revision 6.1.7.0 */
/* Date (dd.mm.yyyy): 29. 6.2021 Time (hh:mm): 21:48 */
/*******************************************************************************/
#define VAR_0
#include <stddef.h>
#include "IMPORT_0"
#include "IMPORT_1"
static CLASS_0 *gx_studio_nested_widget_create(CLASS_1 *control, CLASS_2 VAR_1 *VAR_2, CLASS_0 *parent);
CLASS_3 VAR_4;
CLASS_4 main_display_control_block;
CLASS_5 VAR_5;
CLASS_6 VAR_6;
extern CLASS_2 GX_THEME *VAR_7[];
extern CLASS_2 GX_STRING *VAR_8[];
CLASS_7 h750_180_90_display_table[1] =
{
{
"main_display",
"main_display_canvas",
VAR_7,
VAR_8,
VAR_9,
VAR_10,
VAR_11,
160, /* x resolution */
80, /* y resolution */
&main_display_control_block,
&VAR_6,
&VAR_5,
GX_NULL, /* canvas memory area */
25600, /* canvas memory size in bytes */
VAR_12 /* rotation angle */
}
};
CLASS_8 FUNC_0(CLASS_2 VAR_1 *VAR_14, CLASS_0 *VAR_15, CLASS_0 *parent)
{
CLASS_8 status;
CLASS_9 *VAR_17 = (CLASS_9 *) VAR_15;
CLASS_10 *VAR_18 = (CLASS_10 *) VAR_14->VAR_19;
status = FUNC_1(VAR_17, VAR_14->widget_name, parent, VAR_18->VAR_20, VAR_14->VAR_21, VAR_14->VAR_22, &VAR_14->VAR_23);
if (status == VAR_24)
{
FUNC_2(VAR_17, VAR_18->VAR_25);
#if defined(GUIX_5_4_0_COMPATIBILITY)
FUNC_3(VAR_17, VAR_18->VAR_26, VAR_18->VAR_27);
#else
FUNC_3(VAR_17, VAR_18->VAR_26, VAR_18->VAR_27, VAR_18->disabled_text_color_id);
#endif
}
return status;
}
CLASS_8 gx_studio_window_create(CLASS_2 VAR_1 *VAR_14, CLASS_0 *VAR_15, CLASS_0 *parent)
{
CLASS_8 status;
CLASS_11 *VAR_4 = (CLASS_11 *) VAR_15;
CLASS_12 *VAR_18 = (CLASS_12 *) VAR_14->VAR_19;
status = FUNC_4(VAR_4, VAR_14->widget_name, parent, VAR_14->VAR_21, VAR_14->VAR_22, &VAR_14->VAR_23);
if (status == VAR_24)
{
if (VAR_18->VAR_28)
{
FUNC_5(VAR_4, VAR_18->VAR_28, VAR_14->VAR_21 & VAR_29);
}
}
return status;
}
CLASS_12 VAR_30 =
{
0 /* wallpaper pixelmap id */
};
CLASS_10 VAR_31 =
{
VAR_32, /* string id */
GX_FONT_ID_PROMPT, /* font id */
GX_COLOR_ID_TEXT, /* normal text color */
VAR_33, /* selected text color */
VAR_34 /* disabled text color */
};
CLASS_2 VAR_1 VAR_35 =
{
"prompt",
VAR_36, /* widget type */
GX_ID_NONE, /* widget id */
#if defined(VAR_37)
0, /* user data */
#endif
VAR_38|VAR_39|VAR_40, /* style flags */
VAR_41, /* status flags */
sizeof(VAR_16), /* control block size */
GX_COLOR_ID_WIDGET_FILL, /* normal color id */
GX_COLOR_ID_SELECTED_FILL, /* selected color id */
GX_COLOR_ID_DISABLED_FILL, /* disabled color id */
VAR_13, /* create function */
GX_NULL, /* drawing function override */
GX_NULL, /* event function override */
{21, 22, 100, 45}, /* widget size */
GX_NULL, /* no next widget */
GX_NULL, /* no child widgets */
offsetof(ID_0, window_prompt), /* control block */
(void *) &VAR_31 /* extended properties */
};
CLASS_2 VAR_1 VAR_42 =
{
"window",
VAR_43, /* widget type */
GX_ID_NONE, /* widget id */
#if defined(VAR_37)
0, /* user data */
#endif
VAR_38|VAR_39, /* style flags */
VAR_41, /* status flags */
sizeof(VAR_3), /* control block size */
GX_COLOR_ID_WINDOW_FILL, /* normal color id */
GX_COLOR_ID_WINDOW_FILL, /* selected color id */
GX_COLOR_ID_DISABLED_FILL, /* disabled color id */
gx_studio_window_create, /* create function */
GX_NULL, /* drawing function override */
GX_NULL, /* event function override */
{0, 0, 179, 89}, /* widget size */
GX_NULL, /* next widget */
&VAR_35, /* child widget */
0, /* control block */
(void *) &VAR_30 /* extended properties */
};
CLASS_2 VAR_44 VAR_45[] =
{
{ &VAR_42, (CLASS_0 *) &VAR_4 },
{GX_NULL, GX_NULL}
};
static CLASS_0 *gx_studio_nested_widget_create(CLASS_1 *control, CLASS_2 VAR_1 *VAR_2, CLASS_0 *parent)
{
CLASS_8 status = VAR_24;
CLASS_0 *VAR_46 = GX_NULL;
CLASS_13 list_count = 0;
CLASS_13 VAR_48 = 0;
if(parent && (parent->VAR_49 == VAR_50))
{
VAR_48 = ((CLASS_14 *)parent)->gx_menu_list_total_count;
}
while(VAR_2 && status == VAR_24)
{
if (VAR_2->create_function)
{
if (VAR_2->VAR_21 & GX_STYLE_DYNAMICALLY_ALLOCATED)
{
status = FUNC_6(&VAR_46, VAR_2->VAR_51);
if (status != VAR_24)
{
return GX_NULL;
}
}
else
{
if (control == GX_NULL)
{
return GX_NULL;
}
VAR_46 = (CLASS_0 *) (control + VAR_2->control_block_offset);
}
status = VAR_2->create_function(VAR_2, VAR_46, parent);
if(list_count < VAR_48)
{
FUNC_7((CLASS_14 *)parent, VAR_46);
((CLASS_14 *)parent)->gx_menu_list_total_count--;
list_count++;
}
if (status == VAR_24)
{
if (VAR_2->widget_type != VAR_52)
{
#if defined(GUIX_5_4_0_COMPATIBILITY)
gx_widget_fill_color_set(VAR_46, VAR_2->VAR_53, VAR_2->VAR_54);
#else
gx_widget_fill_color_set(VAR_46, VAR_2->VAR_53, VAR_2->VAR_54, VAR_2->disabled_fill_color_id);
#endif
}
if (!(VAR_2->status & VAR_41))
{
gx_widget_status_remove(VAR_46, VAR_41);
}
if (VAR_2->VAR_55)
{
FUNC_8(VAR_46, VAR_2->VAR_55);
}
if (VAR_2->event_function)
{
FUNC_9(VAR_46, VAR_2->event_function);
}
#if defined(VAR_37)
VAR_46->VAR_56 = VAR_2->VAR_57;
#endif
if (VAR_2->child_widget)
{
gx_studio_nested_widget_create(control, VAR_2->child_widget, VAR_46);
}
}
VAR_2 = VAR_2->VAR_58;
}
}
return VAR_46;
}
CLASS_0 *gx_studio_widget_create(CLASS_1 *control, CLASS_2 VAR_1 *VAR_2, CLASS_0 *parent)
{
CLASS_0 *VAR_46;
VAR_46 = gx_studio_nested_widget_create(control, VAR_2, GX_NULL);
if (parent && VAR_46)
{
gx_widget_attach(parent, VAR_46);
}
return VAR_46;
}
CLASS_8 FUNC_10(char *VAR_59, CLASS_0 *parent, CLASS_0 **new_widget)
{
CLASS_8 status = GX_FAILURE;
CLASS_2 VAR_44 *entry = VAR_45;
CLASS_0 *VAR_46 = GX_NULL;
while(entry->widget_information)
{
if (!FUNC_11(VAR_59, entry->widget_information->widget_name))
{
VAR_46 = gx_studio_widget_create((CLASS_1 *) entry->VAR_46, entry->widget_information, parent);
if (VAR_46)
{
status = VAR_24;
}
break;
}
entry++;
}
if (new_widget)
{
*new_widget = VAR_46;
}
return status;
}
CLASS_8 gx_studio_display_configure(CLASS_15 display, CLASS_8 (*driver)(CLASS_4 *),
CLASS_16 VAR_60, CLASS_15 theme, CLASS_5 **VAR_61)
{
CLASS_2 GX_THEME *theme_ptr;
GX_RECTANGLE VAR_23;
CLASS_7 *VAR_62 = &h750_180_90_display_table[display];
/* create the requested display */
FUNC_12(VAR_62->display,
VAR_62->VAR_59,
driver,
(ID_1) VAR_62->VAR_63,
(ID_1) VAR_62->VAR_64);
/* install the request theme */
if(VAR_62->VAR_65)
{
theme_ptr = VAR_62->VAR_65[theme];
if(theme_ptr)
{
FUNC_13(VAR_62->display, theme_ptr->VAR_66, theme_ptr->theme_color_table_size);
/* install the color palette if required */
if (VAR_62->display->VAR_67 &&
theme_ptr->VAR_68 != NULL)
{
VAR_62->display->FUNC_14(VAR_62->display, theme_ptr->VAR_68, theme_ptr->theme_palette_size);
}
FUNC_15(VAR_62->display, theme_ptr->VAR_69, theme_ptr->VAR_70);
FUNC_16(VAR_62->display, theme_ptr->theme_pixelmap_table, theme_ptr->VAR_71);
gx_system_scroll_appearance_set(theme_ptr->VAR_72, (GX_SCROLLBAR_APPEARANCE *) &theme_ptr->theme_vertical_scrollbar_appearance);
gx_system_scroll_appearance_set(theme_ptr->VAR_73, (GX_SCROLLBAR_APPEARANCE *) &theme_ptr->theme_horizontal_scrollbar_appearance);
FUNC_17(VAR_62->display, VAR_62->VAR_74, (ID_2) VAR_62->language_table_size, VAR_62->VAR_75);
gx_display_active_language_set(VAR_62->display, VAR_60);
}
}
/* Set screen rotation angle. */
VAR_62->display->VAR_76 = VAR_62->VAR_77;
/* create the canvas for this display */
gx_canvas_create(VAR_62->VAR_78,
VAR_62->VAR_79,
VAR_62->display,
VAR_80 | VAR_81,
VAR_62->VAR_63,
VAR_62->VAR_64,
VAR_62->canvas_memory,
VAR_62->canvas_memory_size);
/* Create the root window for this canvas */
FUNC_18(&VAR_23,
0, 0,
(VAR_47) (VAR_62->VAR_63 - 1),
(VAR_47) (VAR_62->VAR_64 - 1));
FUNC_19(VAR_62->VAR_82,
VAR_62->VAR_59,
VAR_62->VAR_78, GX_STYLE_NONE, 0, &VAR_23);
if (VAR_61)
{
*VAR_61 = VAR_62->VAR_82;
}
return VAR_24;
}
#undef GUIX_STUDIO_GENERATED_FILE
| 0.663974 | {'VAR_0': 'GUIX_STUDIO_GENERATED_FILE', 'IMPORT_0': 'h750_180_90_resources.h', 'IMPORT_1': 'h750_180_90_specifications.h', 'CLASS_0': 'GX_WIDGET', 'CLASS_1': 'GX_BYTE', 'CLASS_2': 'GX_CONST', 'VAR_1': 'GX_STUDIO_WIDGET', 'VAR_2': 'definition', 'CLASS_3': 'WINDOW_CONTROL_BLOCK', 'ID_0': 'WINDOW_CONTROL_BLOCK', 'VAR_3': 'WINDOW_CONTROL_BLOCK', 'VAR_4': 'window', 'CLASS_4': 'GX_DISPLAY', 'CLASS_5': 'GX_WINDOW_ROOT', 'VAR_5': 'main_display_root_window', 'CLASS_6': 'GX_CANVAS', 'VAR_6': 'main_display_canvas_control_block', 'VAR_7': 'main_display_theme_table', 'VAR_8': 'main_display_language_table', 'CLASS_7': 'GX_STUDIO_DISPLAY_INFO', 'VAR_9': 'MAIN_DISPLAY_THEME_TABLE_SIZE', 'VAR_10': 'MAIN_DISPLAY_LANGUAGE_TABLE_SIZE', 'VAR_11': 'MAIN_DISPLAY_STRING_TABLE_SIZE', 'VAR_12': 'GX_SCREEN_ROTATION_NONE', 'CLASS_8': 'UINT', 'FUNC_0': 'gx_studio_prompt_create', 'VAR_13': 'gx_studio_prompt_create', 'VAR_14': 'info', 'VAR_15': 'control_block', 'CLASS_9': 'GX_PROMPT', 'VAR_16': 'GX_PROMPT', 'VAR_17': 'prompt', 'CLASS_10': 'GX_PROMPT_PROPERTIES', 'VAR_18': 'props', 'VAR_19': 'properties', 'FUNC_1': 'gx_prompt_create', 'VAR_20': 'string_id', 'VAR_21': 'style', 'VAR_22': 'widget_id', 'VAR_23': 'size', 'VAR_24': 'GX_SUCCESS', 'FUNC_2': 'gx_prompt_font_set', 'VAR_25': 'font_id', 'FUNC_3': 'gx_prompt_text_color_set', 'VAR_26': 'normal_text_color_id', 'VAR_27': 'selected_text_color_id', 'CLASS_11': 'GX_WINDOW', 'CLASS_12': 'GX_WINDOW_PROPERTIES', 'FUNC_4': 'gx_window_create', 'VAR_28': 'wallpaper_id', 'FUNC_5': 'gx_window_wallpaper_set', 'VAR_29': 'GX_STYLE_TILE_WALLPAPER', 'VAR_30': 'window_properties', 'VAR_31': 'window_prompt_properties', 'VAR_32': 'GX_STRING_ID_STRING_3', 'VAR_33': 'GX_COLOR_ID_SELECTED_TEXT', 'VAR_34': 'GX_COLOR_ID_DISABLED_TEXT', 'VAR_35': 'window_prompt_define', 'VAR_36': 'GX_TYPE_PROMPT', 'VAR_37': 'GX_WIDGET_USER_DATA', 'VAR_38': 'GX_STYLE_BORDER_THIN', 'VAR_39': 'GX_STYLE_ENABLED', 'VAR_40': 'GX_STYLE_TEXT_CENTER', 'VAR_41': 'GX_STATUS_ACCEPTS_FOCUS', 'VAR_42': 'window_define', 'VAR_43': 'GX_TYPE_WINDOW', 'VAR_44': 'GX_STUDIO_WIDGET_ENTRY', 'VAR_45': 'h750_180_90_widget_table', 'VAR_46': 'widget', 'CLASS_13': 'GX_VALUE', 'ID_1': 'GX_VALUE', 'VAR_47': 'GX_VALUE', 'VAR_48': 'list_total_count', 'VAR_49': 'gx_widget_type', 'VAR_50': 'GX_TYPE_MENU', 'CLASS_14': 'GX_MENU', 'FUNC_6': 'gx_widget_allocate', 'VAR_51': 'control_block_size', 'FUNC_7': 'gx_menu_insert', 'VAR_52': 'GX_TYPE_TEMPLATE', 'VAR_53': 'normal_fill_color_id', 'VAR_54': 'selected_fill_color_id', 'VAR_55': 'draw_function', 'FUNC_8': 'gx_widget_draw_set', 'FUNC_9': 'gx_widget_event_process_set', 'VAR_56': 'gx_widget_user_data', 'VAR_57': 'user_data', 'VAR_58': 'next_widget', 'FUNC_10': 'gx_studio_named_widget_create', 'VAR_59': 'name', 'FUNC_11': 'strcmp', 'CLASS_15': 'USHORT', 'CLASS_16': 'GX_UBYTE', 'ID_2': 'GX_UBYTE', 'VAR_60': 'language', 'VAR_61': 'return_root', 'VAR_62': 'display_info', 'FUNC_12': 'gx_display_create', 'VAR_63': 'x_resolution', 'VAR_64': 'y_resolution', 'VAR_65': 'theme_table', 'FUNC_13': 'gx_display_color_table_set', 'VAR_66': 'theme_color_table', 'VAR_67': 'gx_display_driver_palette_set', 'FUNC_14': 'gx_display_driver_palette_set', 'VAR_68': 'theme_palette', 'FUNC_15': 'gx_display_font_table_set', 'VAR_69': 'theme_font_table', 'VAR_70': 'theme_font_table_size', 'FUNC_16': 'gx_display_pixelmap_table_set', 'VAR_71': 'theme_pixelmap_table_size', 'VAR_72': 'theme_vertical_scroll_style', 'VAR_73': 'theme_horizontal_scroll_style', 'FUNC_17': 'gx_display_language_table_set_ext', 'VAR_74': 'language_table', 'VAR_75': 'string_table_size', 'VAR_76': 'gx_display_rotation_angle', 'VAR_77': 'rotation_angle', 'VAR_78': 'canvas', 'VAR_79': 'canvas_name', 'VAR_80': 'GX_CANVAS_MANAGED', 'VAR_81': 'GX_CANVAS_VISIBLE', 'FUNC_18': 'gx_utility_rectangle_define', 'FUNC_19': 'gx_window_root_create', 'VAR_82': 'root_window'} |
#ifndef NAGI_CMD_MISC_H
#define NAGI_CMD_MISC_H
extern u8 *cmd_version(u8 *c);
extern u8 *cmd_shake_screen(u8 *c);
#endif /* NAGI_CMD_MISC_H */
| #ifndef NAGI_CMD_MISC_H
#define NAGI_CMD_MISC_H
extern u8 *cmd_version(u8 *c);
extern u8 *cmd_shake_screen(u8 *c);
#endif /* NAGI_CMD_MISC_H */
| 0.159913 | {} |
// Writes out unstructured mesh data to visit
void write_unstructured_to_visit_3d(const int nnodes, int ncells,
const int step, double* nodes_x,
double* nodes_y, double* nodes_z,
const int* cells_to_nodes,
const double* arr, const int nodal,
const int quads) {
#ifdef SILO
double* coords[] = {(double*)nodes_x, (double*)nodes_y, (double*)nodes_z};
int shapecounts[] = {ncells};
int shapesize[] = {8};
int shapetype[] = {DB_ZONETYPE_HEX};
int ndims = 3;
int nshapes = 1;
char filename[MAX_STR_LEN];
sprintf(filename, "output%04d.silo", step);
DBfile* dbfile =
DBCreate(filename, DB_CLOBBER, DB_LOCAL, "simulation time step", DB_HDF5);
DBPutZonelist2(dbfile, "zonelist", ncells, ndims, cells_to_nodes,
ncells * shapesize[0], 0, 0, 0, shapetype, shapesize,
shapecounts, nshapes, NULL);
DBPutUcdmesh(dbfile, "mesh", ndims, NULL, coords, nnodes, ncells, "zonelist",
NULL, DB_DOUBLE, NULL);
DBPutUcdvar1(dbfile, "arr", "mesh", arr, (nodal ? nnodes : ncells), NULL, 0,
DB_DOUBLE, (nodal ? DB_NODECENT : DB_ZONECENT), NULL);
DBClose(dbfile);
#endif
} | // Writes out unstructured mesh data to visit
void write_unstructured_to_visit_3d(const int VAR_0, int ncells,
const int step, double* VAR_1,
double* nodes_y, double* nodes_z,
const int* cells_to_nodes,
const double* arr, const int nodal,
const int quads) {
#ifdef VAR_2
double* coords[] = {(double*)VAR_1, (double*)nodes_y, (double*)nodes_z};
int VAR_3[] = {ncells};
int shapesize[] = {8};
int shapetype[] = {DB_ZONETYPE_HEX};
int ndims = 3;
int nshapes = 1;
char VAR_4[MAX_STR_LEN];
sprintf(VAR_4, "output%04d.silo", step);
CLASS_0* dbfile =
DBCreate(VAR_4, DB_CLOBBER, DB_LOCAL, "simulation time step", VAR_5);
FUNC_0(dbfile, "zonelist", ncells, ndims, cells_to_nodes,
ncells * shapesize[0], 0, 0, 0, shapetype, shapesize,
VAR_3, nshapes, NULL);
DBPutUcdmesh(dbfile, "mesh", ndims, NULL, coords, VAR_0, ncells, "zonelist",
NULL, DB_DOUBLE, NULL);
DBPutUcdvar1(dbfile, "arr", "mesh", arr, (nodal ? VAR_0 : ncells), NULL, 0,
DB_DOUBLE, (nodal ? VAR_6 : DB_ZONECENT), NULL);
DBClose(dbfile);
#endif
} | 0.297662 | {'VAR_0': 'nnodes', 'VAR_1': 'nodes_x', 'VAR_2': 'SILO', 'VAR_3': 'shapecounts', 'VAR_4': 'filename', 'CLASS_0': 'DBfile', 'VAR_5': 'DB_HDF5', 'FUNC_0': 'DBPutZonelist2', 'VAR_6': 'DB_NODECENT'} |
/*
* This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
*
* Copyright 2007-2020 Broadcom Inc. All rights reserved.
*/
/*
* Configuration example start:
*
* cint;
* cint_reset();
* exit;
* cint ../../../src/examples/dnx/field/cint_field_trap_code_no_sys_hdr.c
* cint;
* int unit = 0;
* bcm_field_presel_t presel_id = 50;
* uint32 trap_code = 15;
* uint32 trap_mask = 15;
* field_trap_code_no_sys_hdr_main(unit, presel_id, trap_code, trap_mask);
*
* Configuration example end
*
* This CINT creates a new context and configures it to not use any system header,
* then it adds a preselector of the given trap_code/trap_mask for the new context.
* The preselector presel_id is also given.
*/
bcm_field_context_t context_id;
bcm_field_presel_entry_id_t presel_entry_id;
int field_trap_code_no_sys_hdr_main(int unit, bcm_field_presel_t presel_id, uint32 trap_code, uint32 trap_mask)
{
bcm_field_presel_entry_data_t presel_data;
bcm_field_context_info_t context_info;
bcm_field_context_param_info_t context_param;
int rv = BCM_E_NONE;
printf("Creating new context...\r\n");
bcm_field_context_info_t_init(&context_info);
rv = bcm_field_context_create(unit, 0, bcmFieldStageIngressPMF1, &context_info, &context_id);
if (rv != BCM_E_NONE)
{
printf("Error (%d), in bcm_field_context_create\n", rv);
return rv;
}
printf("Successfully created new context %d\r\n", context_id);
printf("Changing new context SYS HDR profile to None (No SYS HDRs are added)...\r\n");
context_param.param_type = bcmFieldContextParamTypeSystemHeaderProfile;
context_param.param_arg = 0;
context_param.param_val = bcmFieldSystemHeaderProfileNone;
rv = bcm_field_context_param_set(unit, 0, bcmFieldStageIngressPMF1, context_id, &context_param);
if (rv != BCM_E_NONE)
{
printf("Error (%d), in bcm_field_context_param_set\n", rv);
return rv;
}
printf("Adding trap_code preselector for the context...\r\n");
presel_entry_id.presel_id = presel_id;
presel_entry_id.stage = bcmFieldStageIngressPMF1;
presel_data.entry_valid = TRUE;
presel_data.context_id = context_id;
presel_data.nof_qualifiers = 1;
presel_data.qual_data[0].qual_type = bcmFieldQualifyRxTrapCode;
presel_data.qual_data[0].qual_value = trap_code;
presel_data.qual_data[0].qual_mask = trap_mask;
rv = bcm_field_presel_set(unit, 0, &presel_entry_id, &presel_data);
if (rv != BCM_E_NONE)
{
printf("Error (%d), in bcm_field_presel_set\n", rv);
return rv;
}
printf("CINT loaded successfully\r\n");
return rv;
}
int field_trap_code_no_sys_hdr_destroy(int unit)
{
bcm_field_presel_entry_data_t presel_data;
int rv = BCM_E_NONE;
printf("Disabling preselector...\r\n");
presel_data.entry_valid = FALSE;
rv = bcm_field_presel_set(unit, 0, &presel_entry_id, &presel_data);
if (rv != BCM_E_NONE)
{
printf("Error (%d), in bcm_field_presel_set\n", rv);
return rv;
}
printf("Destroying context...\r\n");
rv = bcm_field_context_destroy(unit, bcmFieldStageIngressPMF1, context_id);
if (rv != BCM_E_NONE)
{
printf("Error (%d), in bcm_field_context_destroy context_id %d \n", rv, context_id);
return rv;
}
printf("CINT destroyed successfully\r\n");
return rv;
}
| /*
* This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
*
* Copyright 2007-2020 Broadcom Inc. All rights reserved.
*/
/*
* Configuration example start:
*
* cint;
* cint_reset();
* exit;
* cint ../../../src/examples/dnx/field/cint_field_trap_code_no_sys_hdr.c
* cint;
* int unit = 0;
* bcm_field_presel_t presel_id = 50;
* uint32 trap_code = 15;
* uint32 trap_mask = 15;
* field_trap_code_no_sys_hdr_main(unit, presel_id, trap_code, trap_mask);
*
* Configuration example end
*
* This CINT creates a new context and configures it to not use any system header,
* then it adds a preselector of the given trap_code/trap_mask for the new context.
* The preselector presel_id is also given.
*/
bcm_field_context_t context_id;
bcm_field_presel_entry_id_t presel_entry_id;
int FUNC_0(int VAR_0, bcm_field_presel_t presel_id, uint32 VAR_1, uint32 trap_mask)
{
bcm_field_presel_entry_data_t presel_data;
bcm_field_context_info_t VAR_2;
bcm_field_context_param_info_t VAR_3;
int VAR_4 = BCM_E_NONE;
FUNC_1("Creating new context...\r\n");
bcm_field_context_info_t_init(&VAR_2);
VAR_4 = bcm_field_context_create(VAR_0, 0, bcmFieldStageIngressPMF1, &VAR_2, &context_id);
if (VAR_4 != BCM_E_NONE)
{
FUNC_1("Error (%d), in bcm_field_context_create\n", VAR_4);
return VAR_4;
}
FUNC_1("Successfully created new context %d\r\n", context_id);
FUNC_1("Changing new context SYS HDR profile to None (No SYS HDRs are added)...\r\n");
VAR_3.param_type = bcmFieldContextParamTypeSystemHeaderProfile;
VAR_3.param_arg = 0;
VAR_3.param_val = bcmFieldSystemHeaderProfileNone;
VAR_4 = FUNC_2(VAR_0, 0, bcmFieldStageIngressPMF1, context_id, &VAR_3);
if (VAR_4 != BCM_E_NONE)
{
FUNC_1("Error (%d), in bcm_field_context_param_set\n", VAR_4);
return VAR_4;
}
FUNC_1("Adding trap_code preselector for the context...\r\n");
presel_entry_id.presel_id = presel_id;
presel_entry_id.stage = bcmFieldStageIngressPMF1;
presel_data.entry_valid = TRUE;
presel_data.context_id = context_id;
presel_data.nof_qualifiers = 1;
presel_data.VAR_5[0].qual_type = bcmFieldQualifyRxTrapCode;
presel_data.VAR_5[0].qual_value = VAR_1;
presel_data.VAR_5[0].VAR_6 = trap_mask;
VAR_4 = FUNC_3(VAR_0, 0, &presel_entry_id, &presel_data);
if (VAR_4 != BCM_E_NONE)
{
FUNC_1("Error (%d), in bcm_field_presel_set\n", VAR_4);
return VAR_4;
}
FUNC_1("CINT loaded successfully\r\n");
return VAR_4;
}
int field_trap_code_no_sys_hdr_destroy(int VAR_0)
{
bcm_field_presel_entry_data_t presel_data;
int VAR_4 = BCM_E_NONE;
FUNC_1("Disabling preselector...\r\n");
presel_data.entry_valid = FALSE;
VAR_4 = FUNC_3(VAR_0, 0, &presel_entry_id, &presel_data);
if (VAR_4 != BCM_E_NONE)
{
FUNC_1("Error (%d), in bcm_field_presel_set\n", VAR_4);
return VAR_4;
}
FUNC_1("Destroying context...\r\n");
VAR_4 = bcm_field_context_destroy(VAR_0, bcmFieldStageIngressPMF1, context_id);
if (VAR_4 != BCM_E_NONE)
{
FUNC_1("Error (%d), in bcm_field_context_destroy context_id %d \n", VAR_4, context_id);
return VAR_4;
}
FUNC_1("CINT destroyed successfully\r\n");
return VAR_4;
}
| 0.176599 | {'FUNC_0': 'field_trap_code_no_sys_hdr_main', 'VAR_0': 'unit', 'VAR_1': 'trap_code', 'VAR_2': 'context_info', 'VAR_3': 'context_param', 'VAR_4': 'rv', 'FUNC_1': 'printf', 'FUNC_2': 'bcm_field_context_param_set', 'VAR_5': 'qual_data', 'VAR_6': 'qual_mask', 'FUNC_3': 'bcm_field_presel_set'} |
// Location recorded for un-named parameter is take from the defining declaration on line #10
static void foobar( int abcdefg );
// The location of the named function parameter below is used for that of the un-named parameter above.
// This causes comments to be incorrectly woven into the AST and unparsed incorrectly. This in turn
#include "test2012_75.h"
// causes the gene4ated code to not compile properly (effects grep fts.c file).
static void foobar( int xyz )
{
}
|
// Location recorded for un-named parameter is take from the defining declaration on line #10
static void FUNC_0( int VAR_0 );
// The location of the named function parameter below is used for that of the un-named parameter above.
// This causes comments to be incorrectly woven into the AST and unparsed incorrectly. This in turn
#include "test2012_75.h"
// causes the gene4ated code to not compile properly (effects grep fts.c file).
static void FUNC_0( int xyz )
{
}
| 0.11207 | {'FUNC_0': 'foobar', 'VAR_0': 'abcdefg'} |
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef HOS_CAMERA_VENC_NODE_H
#define HOS_CAMERA_VENC_NODE_H
#include <stdint.h>
#include "mpi_node.h"
#include "sink_node.h"
#include "device_manager_adapter.h"
#include "mpi_device_manager.h"
#include "camera.h"
#include "venc_controller.h"
#include "venc_manager.h"
namespace OHOS::Camera {
class VencNode : public MpiNode, public SinkNode {
public:
VencNode(const std::string& name, const std::string& type);
~VencNode() override;
RetCode Start(const int32_t streamId) override;
RetCode Stop(const int32_t streamId) override;
RetCode GetDeviceController() const;
};
} // namespace OHOS::Camera
#endif
| /*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef HOS_CAMERA_VENC_NODE_H
#define HOS_CAMERA_VENC_NODE_H
#include <stdint.h>
#include "IMPORT_0"
#include "IMPORT_1"
#include "device_manager_adapter.h"
#include "mpi_device_manager.h"
#include "camera.h"
#include "venc_controller.h"
#include "venc_manager.h"
CLASS_0 OHOS::Camera {
class VencNode : public MpiNode, public SinkNode {
public:
VencNode(const std::string& name, const std::string& type);
~VencNode() VAR_0;
RetCode Start(const int32_t streamId) VAR_0;
RetCode Stop(const int32_t streamId) VAR_0;
RetCode GetDeviceController() const;
};
} // namespace OHOS::Camera
#endif
| 0.103738 | {'IMPORT_0': 'mpi_node.h', 'IMPORT_1': 'sink_node.h', 'CLASS_0': 'namespace', 'VAR_0': 'override'} |
#ifndef __Panel_H__
#define __Panel_H__
class Panel
{
public:
Panel();
virtual ~Panel();
void ToggleActive();
bool IsActive() const;
void ResizePanel();
virtual void Draw() {};
protected:
bool active = true;
char* name = nullptr;
int pos_x, pos_y, width, height;
bool resize = true;
};
#endif | #ifndef VAR_0
#define VAR_0
class VAR_1
{
public:
FUNC_0();
virtual ~FUNC_0();
void FUNC_1();
bool FUNC_2() const;
void FUNC_3();
virtual VAR_2 Draw() {};
protected:
bool VAR_3 = true;
char* name = nullptr;
int pos_x, VAR_4, VAR_5, VAR_6;
bool VAR_7 = true;
};
#endif | 0.734568 | {'VAR_0': '__Panel_H__', 'VAR_1': 'Panel', 'FUNC_0': 'Panel', 'FUNC_1': 'ToggleActive', 'FUNC_2': 'IsActive', 'FUNC_3': 'ResizePanel', 'VAR_2': 'void', 'VAR_3': 'active', 'VAR_4': 'pos_y', 'VAR_5': 'width', 'VAR_6': 'height', 'VAR_7': 'resize'} |
/* -------------------------------------------------------------------------- */
/* construct a file name from a file number (not user-callable) */
/* -------------------------------------------------------------------------- */
static void make_filename (Int filenum, char *prefix, char *filename)
{
char *psrc, *pdst ;
#ifdef DLONG
sprintf (filename, "%s%ld.umf", prefix, filenum) ;
#else
sprintf (filename, "%s%d.umf", prefix, filenum) ;
#endif
pdst = filename ;
for (psrc = filename ; *psrc ; psrc++)
{
if (!isspace (*psrc)) *pdst++ = *psrc ;
}
*pdst = '\0' ;
} | /* -------------------------------------------------------------------------- */
/* construct a file name from a file number (not user-callable) */
/* -------------------------------------------------------------------------- */
static void FUNC_0 (Int VAR_0, char *VAR_1, char *VAR_2)
{
char *VAR_3, *VAR_4 ;
#ifdef VAR_5
FUNC_1 (VAR_2, "%s%ld.umf", VAR_1, VAR_0) ;
#else
FUNC_1 (VAR_2, "%s%d.umf", VAR_1, VAR_0) ;
#endif
VAR_4 = VAR_2 ;
for (VAR_3 = VAR_2 ; *VAR_3 ; VAR_3++)
{
if (!isspace (*VAR_3)) *VAR_4++ = *VAR_3 ;
}
*VAR_4 = '\0' ;
} | 0.735951 | {'FUNC_0': 'make_filename', 'VAR_0': 'filenum', 'VAR_1': 'prefix', 'VAR_2': 'filename', 'VAR_3': 'psrc', 'VAR_4': 'pdst', 'VAR_5': 'DLONG', 'FUNC_1': 'sprintf'} |
//
// Copyright 2020 WebAssembly Community Group participants
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef WASP_TEXT_WRITE_H_
#define WASP_TEXT_WRITE_H_
#include <algorithm>
#include <cassert>
#include <string>
#include <type_traits>
#include "wasp/base/concat.h"
#include "wasp/base/formatters.h"
#include "wasp/base/types.h"
#include "wasp/base/v128.h"
#include "wasp/text/numeric.h"
#include "wasp/text/types.h"
namespace wasp::text {
struct WriteCtx {
void ClearSeparator() { separator = ""; }
void Space() { separator = " "; }
void Newline() { separator = indent; }
void Indent() { indent += " "; }
void DedentWithMinimum(size_t minimum) {
if (indent.size() > minimum) {
indent.erase(indent.size() - 2);
}
}
void Dedent() { DedentWithMinimum(2); }
void DedentNoToplevel() { DedentWithMinimum(3); }
std::string separator;
std::string indent = "\n";
Base base = Base::Decimal;
};
// WriteRaw
template <typename Iterator>
Iterator WriteRaw(WriteCtx& ctx, char value, Iterator out) {
*out++ = value;
return out;
}
template <typename Iterator>
Iterator WriteRaw(WriteCtx& ctx, string_view value, Iterator out) {
return std::copy(value.begin(), value.end(), out);
}
template <typename Iterator>
Iterator WriteRaw(WriteCtx& ctx, const std::string& value, Iterator out) {
return std::copy(value.begin(), value.end(), out);
}
template <typename Iterator>
Iterator WriteSeparator(WriteCtx& ctx, Iterator out) {
out = WriteRaw(ctx, ctx.separator, out);
ctx.ClearSeparator();
return out;
}
// WriteFormat
template <typename Iterator, typename T>
Iterator WriteFormat(WriteCtx& ctx, const T& value, Iterator out) {
out = WriteSeparator(ctx, out);
out = WriteRaw(ctx, concat(value), out);
ctx.Space();
return out;
}
template <typename Iterator>
Iterator WriteLpar(WriteCtx& ctx, Iterator out) {
out = WriteSeparator(ctx, out);
out = WriteRaw(ctx, '(', out);
return out;
}
template <typename Iterator>
Iterator WriteLpar(WriteCtx& ctx, string_view name, Iterator out) {
out = WriteLpar(ctx, out);
out = WriteRaw(ctx, name, out);
ctx.Space();
return out;
}
template <typename Iterator>
Iterator WriteRpar(WriteCtx& ctx, Iterator out) {
ctx.ClearSeparator();
out = WriteRaw(ctx, ')', out);
ctx.Space();
return out;
}
template <typename Iterator, typename SourceIter>
Iterator WriteRange(WriteCtx& ctx,
SourceIter begin,
SourceIter end,
Iterator out) {
for (auto iter = begin; iter != end; ++iter) {
out = Write(ctx, *iter, out);
}
return out;
}
template <typename Iterator, typename T>
Iterator WriteVector(WriteCtx& ctx,
const std::vector<T>& values,
Iterator out) {
return WriteRange(ctx, values.begin(), values.end(), out);
}
template <typename Iterator, typename T>
Iterator Write(WriteCtx& ctx, const optional<T>& value_opt, Iterator out) {
if (value_opt) {
out = Write(ctx, *value_opt, out);
}
return out;
}
template <typename Iterator, typename T>
Iterator Write(WriteCtx& ctx, const At<T>& value, Iterator out) {
return Write(ctx, *value, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, string_view value, Iterator out) {
out = WriteSeparator(ctx, out);
out = WriteRaw(ctx, value, out);
ctx.Space();
return out;
}
template <typename Iterator, typename T>
Iterator WriteNat(WriteCtx& ctx, const At<T>& value, Iterator out) {
return WriteNat(ctx, *value, out);
}
template <typename Iterator, typename T>
Iterator WriteInt(WriteCtx& ctx, const At<T>& value, Iterator out) {
return WriteInt(ctx, *value, out);
}
template <typename Iterator, typename T>
Iterator WriteFloat(WriteCtx& ctx, const At<T>& value, Iterator out) {
return WriteFloat(ctx, *value, out);
}
template <typename Iterator, typename T>
Iterator WriteNat(WriteCtx& ctx, T value, Iterator out) {
return Write(ctx, string_view{NatToStr<T>(value, ctx.base)}, out);
}
template <typename Iterator, typename T>
Iterator WriteInt(WriteCtx& ctx, T value, Iterator out) {
return Write(ctx, string_view{IntToStr<T>(value, ctx.base)}, out);
}
template <typename Iterator, typename T >
Iterator WriteFloat(WriteCtx& ctx, T value, Iterator out) {
return Write(ctx, string_view{FloatToStr<T>(value, ctx.base)}, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, Var value, Iterator out) {
if (value.is_index()) {
return WriteNat(ctx, value.index(), out);
} else {
return Write(ctx, value.name(), out);
}
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const VarList& values, Iterator out) {
return WriteVector(ctx, values, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Text& value, Iterator out) {
return Write(ctx, value.text, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const TextList& values, Iterator out) {
return WriteVector(ctx, values, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ValueType& value, Iterator out) {
return WriteFormat(ctx, value, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ValueTypeList& values, Iterator out) {
return WriteVector(ctx, values, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx,
const ValueTypeList& values,
string_view name,
Iterator out) {
if (!values.empty()) {
out = WriteLpar(ctx, name, out);
out = Write(ctx, values, out);
out = WriteRpar(ctx, out);
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const StorageType& value, Iterator out) {
return WriteFormat(ctx, value, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const FieldType& value, Iterator out) {
out = WriteLpar(ctx, "field", out);
out = Write(ctx, value.name, out);
if (value.mut == Mutability::Var) {
out = WriteLpar(ctx, "mut", out);
}
out = Write(ctx, value.type, out);
if (value.mut == Mutability::Var) {
out = WriteRpar(ctx, out);
}
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const FieldTypeList& values, Iterator out) {
bool first = true;
bool prev_has_name = false;
for (auto& value : values) {
bool has_name = value->name.has_value();
if ((has_name || prev_has_name) && !first) {
out = WriteRpar(ctx, out);
}
if (has_name || prev_has_name || first) {
out = WriteLpar(ctx, "field", out);
}
if (has_name) {
out = Write(ctx, value->name, out);
}
if (value->mut == Mutability::Var) {
out = WriteLpar(ctx, "mut", out);
}
out = Write(ctx, value->type, out);
if (value->mut == Mutability::Var) {
out = WriteRpar(ctx, out);
}
prev_has_name = has_name;
first = false;
}
if (!values.empty()) {
out = WriteRpar(ctx, out);
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const StructType& value, Iterator out) {
out = WriteLpar(ctx, "struct", out);
out = Write(ctx, value.fields, out);
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ArrayType& value, Iterator out) {
out = WriteLpar(ctx, "array", out);
out = Write(ctx, value.field, out);
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const FunctionType& value, Iterator out) {
out = Write(ctx, value.params, "param", out);
out = Write(ctx, value.results, "result", out);
return out;
}
template <typename Iterator>
Iterator WriteTypeUse(WriteCtx& ctx, const OptAt<Var>& value, Iterator out) {
if (value) {
out = WriteLpar(ctx, "type", out);
out = Write(ctx, value->value(), out);
out = WriteRpar(ctx, out);
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const FunctionTypeUse& value, Iterator out) {
out = WriteTypeUse(ctx, value.type_use, out);
out = Write(ctx, *value.type, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const v128& value, Iterator out) {
u32x4 immediate = value.as<u32x4>();
out = Write(ctx, "i32x4"_sv, out);
for (auto& lane : immediate) {
out = WriteInt(ctx, lane, out);
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const BlockImmediate& value, Iterator out) {
out = Write(ctx, value.label, out);
out = Write(ctx, value.type, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const HeapType2Immediate& value, Iterator out) {
out = Write(ctx, *value.parent, out);
out = Write(ctx, *value.child, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const BrOnCastImmediate& value, Iterator out) {
out = Write(ctx, *value.target, out);
out = Write(ctx, value.types, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const BrTableImmediate& value, Iterator out) {
out = Write(ctx, value.targets, out);
out = Write(ctx, *value.default_target, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx,
const CallIndirectImmediate& value,
Iterator out) {
out = Write(ctx, value.table, out);
out = Write(ctx, value.type, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const CopyImmediate& value, Iterator out) {
out = Write(ctx, value.dst, out);
out = Write(ctx, value.src, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const InitImmediate& value, Iterator out) {
// Write dst first, if it exists.
if (value.dst) {
out = Write(ctx, value.dst->value(), out);
}
out = Write(ctx, *value.segment, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const LetImmediate& value, Iterator out) {
out = Write(ctx, value.block, out);
out = Write(ctx, value.locals, "local", out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const MemArgImmediate& value, Iterator out) {
if (value.memory) {
out = Write(ctx, *value.memory, out);
}
if (value.offset) {
out = Write(ctx, "offset="_sv, out);
ctx.ClearSeparator();
out = WriteNat(ctx, value.offset->value(), out);
}
if (value.align) {
out = Write(ctx, "align="_sv, out);
ctx.ClearSeparator();
out = WriteNat(ctx, value.align->value(), out);
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const MemOptImmediate& value, Iterator out) {
if (value.memory) {
out = Write(ctx, *value.memory, out);
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const RttSubImmediate& value, Iterator out) {
out = WriteNat(ctx, *value.depth, out);
out = Write(ctx, value.types, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ShuffleImmediate& value, Iterator out) {
for (auto& lane : value) {
out = WriteNat(ctx, lane, out);
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const StructFieldImmediate& value, Iterator out) {
out = Write(ctx, *value.struct_, out);
out = Write(ctx, *value.field, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx,
const SimdMemoryLaneImmediate& value,
Iterator out) {
out = Write(ctx, value.memarg, out);
out = WriteNat(ctx, *value.lane, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Opcode& value, Iterator out) {
return WriteFormat(ctx, value, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Instruction& value, Iterator out) {
out = Write(ctx, *value.opcode, out);
switch (value.kind()) {
case InstructionKind::None:
break;
case InstructionKind::S32:
out = WriteInt(ctx, value.s32_immediate(), out);
break;
case InstructionKind::S64:
out = WriteInt(ctx, value.s64_immediate(), out);
break;
case InstructionKind::F32:
out = WriteFloat(ctx, value.f32_immediate(), out);
break;
case InstructionKind::F64:
out = WriteFloat(ctx, value.f64_immediate(), out);
break;
case InstructionKind::V128:
out = Write(ctx, value.v128_immediate(), out);
break;
case InstructionKind::Var:
out = Write(ctx, value.var_immediate(), out);
break;
case InstructionKind::Block:
out = Write(ctx, value.block_immediate(), out);
break;
case InstructionKind::BrTable:
out = Write(ctx, value.br_table_immediate(), out);
break;
case InstructionKind::CallIndirect:
out = Write(ctx, value.call_indirect_immediate(), out);
break;
case InstructionKind::Copy:
out = Write(ctx, value.copy_immediate(), out);
break;
case InstructionKind::Init:
out = Write(ctx, value.init_immediate(), out);
break;
case InstructionKind::Let:
out = Write(ctx, value.let_immediate(), out);
break;
case InstructionKind::MemArg:
out = Write(ctx, value.mem_arg_immediate(), out);
break;
case InstructionKind::MemOpt:
out = Write(ctx, value.mem_opt_immediate(), out);
break;
case InstructionKind::HeapType:
out = Write(ctx, value.heap_type_immediate(), out);
break;
case InstructionKind::Select:
out = Write(ctx, value.select_immediate(), out);
break;
case InstructionKind::Shuffle:
out = Write(ctx, value.shuffle_immediate(), out);
break;
case InstructionKind::SimdLane:
out = WriteNat(ctx, value.simd_lane_immediate(), out);
break;
case InstructionKind::SimdMemoryLane:
out = Write(ctx, value.simd_memory_lane_immediate(), out);
break;
case InstructionKind::FuncBind:
out = Write(ctx, value.func_bind_immediate(), out);
break;
case InstructionKind::BrOnCast:
out = Write(ctx, value.br_on_cast_immediate(), out);
break;
case InstructionKind::HeapType2:
out = Write(ctx, value.heap_type_2_immediate(), out);
break;
case InstructionKind::RttSub:
out = Write(ctx, value.rtt_sub_immediate(), out);
break;
case InstructionKind::StructField:
out = Write(ctx, value.struct_field_immediate(), out);
break;
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const InstructionList& values, Iterator out) {
return WriteVector(ctx, values, out);
}
template <typename Iterator>
Iterator WriteWithNewlines(WriteCtx& ctx,
const InstructionList& values,
Iterator out) {
// If the instruction list ends with and `end` instruction, don't write it
// (it's implicit in the function definition, in the text format.)
span<const At<Instruction>> instrs{values};
if (!values.empty() && values.back()->opcode == Opcode::End) {
instrs.remove_suffix(1);
}
for (auto& instr : instrs) {
auto opcode = instr->opcode;
if (opcode == Opcode::End || opcode == Opcode::Else ||
opcode == Opcode::Catch || opcode == Opcode::CatchAll ||
opcode == Opcode::Delegate) {
ctx.DedentNoToplevel();
ctx.Newline();
}
out = Write(ctx, instr, out);
if (instr->has_block_immediate() || instr->has_let_immediate() ||
opcode == Opcode::Else || opcode == Opcode::Catch ||
opcode == Opcode::CatchAll) {
ctx.Indent();
}
ctx.Newline();
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const BoundValueType& value, Iterator out) {
out = Write(ctx, value.name, out);
out = Write(ctx, value.type, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx,
const BoundValueTypeList& values,
string_view prefix,
Iterator out) {
bool first = true;
bool prev_has_name = false;
for (auto& value : values) {
bool has_name = value->name.has_value();
if ((has_name || prev_has_name) && !first) {
out = WriteRpar(ctx, out);
}
if (has_name || prev_has_name || first) {
out = WriteLpar(ctx, prefix, out);
}
if (has_name) {
out = Write(ctx, value->name, out);
}
out = Write(ctx, value->type, out);
prev_has_name = has_name;
first = false;
}
if (!values.empty()) {
out = WriteRpar(ctx, out);
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const BoundFunctionType& value, Iterator out) {
out = Write(ctx, value.params, "param", out);
out = Write(ctx, value.results, "result", out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const DefinedType& value, Iterator out) {
out = WriteLpar(ctx, "type", out);
out = Write(ctx, value.name, out);
if (value.is_function_type()) {
out = WriteLpar(ctx, "func", out);
out = Write(ctx, value.function_type(), out);
out = WriteRpar(ctx, out);
} else if (value.is_struct_type()) {
out = Write(ctx, value.struct_type(), out);
} else {
assert(value.is_array_type());
out = Write(ctx, value.array_type(), out);
}
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const FunctionDesc& value, Iterator out) {
out = Write(ctx, "func"_sv, out);
out = Write(ctx, value.name, out);
out = WriteTypeUse(ctx, value.type_use, out);
out = Write(ctx, value.type, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Limits& value, Iterator out) {
if (value.index_type == IndexType::I64) {
out = Write(ctx, "i64"_sv, out);
}
out = WriteNat(ctx, value.min, out);
if (value.max) {
out = WriteNat(ctx, *value.max, out);
}
if (value.shared == Shared::Yes) {
out = Write(ctx, "shared"_sv, out);
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, HeapType value, Iterator out) {
return WriteFormat(ctx, value, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, ReferenceType value, Iterator out) {
return WriteFormat(ctx, value, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Rtt& value, Iterator out) {
out = WriteLpar(ctx, "rtt", out);
out = WriteNat(ctx, value.depth, out);
out = Write(ctx, value.type, out);
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const TableType& value, Iterator out) {
out = Write(ctx, value.limits, out);
out = WriteFormat(ctx, value.elemtype, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const TableDesc& value, Iterator out) {
out = Write(ctx, "table"_sv, out);
out = Write(ctx, value.name, out);
out = Write(ctx, value.type, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const MemoryType& value, Iterator out) {
out = Write(ctx, value.limits, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const MemoryDesc& value, Iterator out) {
out = Write(ctx, "memory"_sv, out);
out = Write(ctx, value.name, out);
out = Write(ctx, value.type, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const GlobalType& value, Iterator out) {
if (value.mut == Mutability::Var) {
out = WriteLpar(ctx, "mut", out);
}
out = Write(ctx, value.valtype, out);
if (value.mut == Mutability::Var) {
out = WriteRpar(ctx, out);
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const GlobalDesc& value, Iterator out) {
out = Write(ctx, "global"_sv, out);
out = Write(ctx, value.name, out);
out = Write(ctx, value.type, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const TagType& value, Iterator out) {
out = Write(ctx, value.type, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const TagDesc& value, Iterator out) {
out = Write(ctx, "tag"_sv, out);
out = Write(ctx, value.name, out);
out = Write(ctx, value.type, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Import& value, Iterator out) {
out = WriteLpar(ctx, "import"_sv, out);
out = Write(ctx, value.module, out);
out = Write(ctx, value.name, out);
out = WriteLpar(ctx, out);
switch (value.kind()) {
case ExternalKind::Function:
out = Write(ctx, value.function_desc(), out);
break;
case ExternalKind::Table:
out = Write(ctx, value.table_desc(), out);
break;
case ExternalKind::Memory:
out = Write(ctx, value.memory_desc(), out);
break;
case ExternalKind::Global:
out = Write(ctx, value.global_desc(), out);
break;
case ExternalKind::Tag:
out = Write(ctx, value.tag_desc(), out);
break;
}
out = WriteRpar(ctx, out);
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const InlineImport& value, Iterator out) {
out = WriteLpar(ctx, "import"_sv, out);
out = Write(ctx, value.module, out);
out = Write(ctx, value.name, out);
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const InlineExport& value, Iterator out) {
out = WriteLpar(ctx, "export"_sv, out);
out = Write(ctx, value.name, out);
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const InlineExportList& values, Iterator out) {
return WriteVector(ctx, values, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Function& value, Iterator out) {
out = WriteLpar(ctx, "func", out);
// Can't write FunctionDesc directly, since inline imports/exports occur
// between the bindvar and the type use.
out = Write(ctx, value.desc.name, out);
out = Write(ctx, value.exports, out);
if (value.import) {
out = Write(ctx, *value.import, out);
}
out = WriteTypeUse(ctx, value.desc.type_use, out);
out = Write(ctx, value.desc.type, out);
if (!value.import) {
ctx.Indent();
ctx.Newline();
out = Write(ctx, value.locals, "local", out);
ctx.Newline();
out = WriteWithNewlines(ctx, value.instructions, out);
ctx.Dedent();
}
out = WriteRpar(ctx, out);
ctx.Newline();
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx,
const ElementExpressionList& elem_exprs,
Iterator out) {
// Use spaces instead of newlines for element expressions.
for (auto& elem_expr : elem_exprs) {
for (auto& instr : elem_expr->instructions) {
// Expressions need to be wrapped in parens.
out = WriteLpar(ctx, out);
out = Write(ctx, instr, out);
out = WriteRpar(ctx, out);
ctx.Space();
}
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx,
const ElementListWithExpressions& value,
Iterator out) {
out = Write(ctx, value.elemtype, out);
out = Write(ctx, value.list, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, ExternalKind value, Iterator out) {
return WriteFormat(ctx, value, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ElementListWithVars& value, Iterator out) {
out = Write(ctx, value.kind, out);
out = Write(ctx, value.list, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ElementList& value, Iterator out) {
if (holds_alternative<ElementListWithVars>(value)) {
return Write(ctx, get<ElementListWithVars>(value), out);
} else {
return Write(ctx, get<ElementListWithExpressions>(value), out);
}
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Table& value, Iterator out) {
out = WriteLpar(ctx, "table", out);
// Can't write TableDesc directly, since inline imports/exports occur after
// the bind var.
out = Write(ctx, value.desc.name, out);
out = Write(ctx, value.exports, out);
if (value.import) {
out = Write(ctx, *value.import, out);
out = Write(ctx, value.desc.type, out);
} else if (value.elements) {
// Don't write the limits, because they are implicitly defined by the
// element segment length.
out = Write(ctx, value.desc.type->elemtype, out);
out = WriteLpar(ctx, "elem", out);
// Only write the list of elements, without the ExternalKind or
// ReferenceType.
if (holds_alternative<ElementListWithVars>(*value.elements)) {
out = Write(ctx, get<ElementListWithVars>(*value.elements).list, out);
} else {
out = Write(ctx,
get<ElementListWithExpressions>(*value.elements).list, out);
}
out = WriteRpar(ctx, out);
} else {
out = Write(ctx, value.desc.type, out);
}
out = WriteRpar(ctx, out);
return out;
}
template <typename T, typename Iterator>
Iterator WriteNumericValues(WriteCtx& ctx,
const NumericData& value,
Iterator out) {
for (Index i = 0; i < value.count(); ++i) {
if constexpr (std::is_same_v<T, v128>) {
out = Write(ctx, value.value<T>(i), out);
} else if constexpr (std::is_floating_point_v<T>) {
out = WriteFloat(ctx, value.value<T>(i), out);
} else {
out = WriteInt(ctx, value.value<T>(i), out);
}
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const NumericData& value, Iterator out) {
switch (value.type) {
case NumericDataType::I8:
out = WriteLpar(ctx, "i8", out);
out = WriteNumericValues<s8>(ctx, value, out);
break;
case NumericDataType::I16:
out = WriteLpar(ctx, "i16", out);
out = WriteNumericValues<s16>(ctx, value, out);
break;
case NumericDataType::I32:
out = WriteLpar(ctx, "i32", out);
out = WriteNumericValues<s32>(ctx, value, out);
break;
case NumericDataType::I64:
out = WriteLpar(ctx, "i64", out);
out = WriteNumericValues<s64>(ctx, value, out);
break;
case NumericDataType::F32:
out = WriteLpar(ctx, "f32", out);
out = WriteNumericValues<f32>(ctx, value, out);
break;
case NumericDataType::F64:
out = WriteLpar(ctx, "f64", out);
out = WriteNumericValues<f64>(ctx, value, out);
break;
case NumericDataType::V128:
out = WriteLpar(ctx, "v128", out);
out = WriteNumericValues<v128>(ctx, value, out);
break;
}
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const DataItem& value, Iterator out) {
if (value.is_text()) {
return Write(ctx, value.text(), out);
} else {
assert(value.is_numeric_data());
return Write(ctx, value.numeric_data(), out);
}
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const DataItemList& values, Iterator out) {
return WriteVector(ctx, values, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Memory& value, Iterator out) {
out = WriteLpar(ctx, "memory", out);
// Can't write MemoryDesc directly, since inline imports/exports occur after
// the bind var.
out = Write(ctx, value.desc.name, out);
out = Write(ctx, value.exports, out);
if (value.import) {
out = Write(ctx, *value.import, out);
out = Write(ctx, value.desc.type, out);
} else if (value.data) {
out = WriteLpar(ctx, "data", out);
out = Write(ctx, value.data, out);
out = WriteRpar(ctx, out);
} else {
out = Write(ctx, value.desc.type, out);
}
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ConstantExpression& value, Iterator out) {
return Write(ctx, value.instructions, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Global& value, Iterator out) {
out = WriteLpar(ctx, "global", out);
// Can't write GlobalDesc directly, since inline imports/exports occur after
// the bind var.
out = Write(ctx, value.desc.name, out);
out = Write(ctx, value.exports, out);
if (value.import) {
out = Write(ctx, *value.import, out);
out = Write(ctx, value.desc.type, out);
} else {
out = Write(ctx, value.desc.type, out);
out = Write(ctx, value.init, out);
}
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Export& value, Iterator out) {
out = WriteLpar(ctx, "export", out);
out = Write(ctx, value.name, out);
out = WriteLpar(ctx, out);
out = Write(ctx, value.kind, out);
out = Write(ctx, value.var, out);
out = WriteRpar(ctx, out);
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Start& value, Iterator out) {
out = WriteLpar(ctx, "start", out);
out = Write(ctx, value.var, out);
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ElementExpression& value, Iterator out) {
return Write(ctx, value.instructions, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ElementSegment& value, Iterator out) {
out = WriteLpar(ctx, "elem", out);
out = Write(ctx, value.name, out);
switch (value.type) {
case SegmentType::Active:
if (value.table) {
out = WriteLpar(ctx, "table", out);
out = Write(ctx, *value.table, out);
out = WriteRpar(ctx, out);
}
if (value.offset) {
out = WriteLpar(ctx, "offset", out);
out = Write(ctx, *value.offset, out);
out = WriteRpar(ctx, out);
}
// When writing a function var list, we can omit the "func" keyword to
// remain compatible with the MVP text format.
if (holds_alternative<ElementListWithVars>(value.elements)) {
auto& element_vars = get<ElementListWithVars>(value.elements);
// The legacy format which omits the external kind cannot be used with
// the "table use" or bind_var syntax.
if (element_vars.kind != ExternalKind::Function || value.table ||
value.name) {
out = Write(ctx, element_vars.kind, out);
}
out = Write(ctx, element_vars.list, out);
} else {
out = Write(ctx, get<ElementListWithExpressions>(value.elements), out);
}
break;
case SegmentType::Passive:
out = Write(ctx, value.elements, out);
break;
case SegmentType::Declared:
out = Write(ctx, "declare"_sv, out);
out = Write(ctx, value.elements, out);
break;
}
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const DataSegment& value, Iterator out) {
out = WriteLpar(ctx, "data", out);
out = Write(ctx, value.name, out);
if (value.type == SegmentType::Active) {
if (value.memory) {
out = WriteLpar(ctx, "memory", out);
out = Write(ctx, *value.memory, out);
out = WriteRpar(ctx, out);
}
if (value.offset) {
out = WriteLpar(ctx, "offset", out);
out = Write(ctx, *value.offset, out);
out = WriteRpar(ctx, out);
}
}
out = Write(ctx, value.data, out);
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Tag& value, Iterator out) {
out = WriteLpar(ctx, "tag", out);
// Can't write TagDesc directly, since inline imports/exports occur after
// the bind var.
out = Write(ctx, value.desc.name, out);
out = Write(ctx, value.exports, out);
if (value.import) {
out = Write(ctx, *value.import, out);
out = Write(ctx, value.desc.type, out);
} else {
out = Write(ctx, value.desc.type, out);
}
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ModuleItem& value, Iterator out) {
switch (value.kind()) {
case ModuleItemKind::DefinedType:
out = Write(ctx, value.defined_type(), out);
break;
case ModuleItemKind::Import:
out = Write(ctx, value.import(), out);
break;
case ModuleItemKind::Function:
out = Write(ctx, value.function(), out);
break;
case ModuleItemKind::Table:
out = Write(ctx, value.table(), out);
break;
case ModuleItemKind::Memory:
out = Write(ctx, value.memory(), out);
break;
case ModuleItemKind::Global:
out = Write(ctx, value.global(), out);
break;
case ModuleItemKind::Export:
out = Write(ctx, value.export_(), out);
break;
case ModuleItemKind::Start:
out = Write(ctx, value.start(), out);
break;
case ModuleItemKind::ElementSegment:
out = Write(ctx, value.element_segment(), out);
break;
case ModuleItemKind::DataSegment:
out = Write(ctx, value.data_segment(), out);
break;
case ModuleItemKind::Tag:
out = Write(ctx, value.tag(), out);
break;
}
ctx.Newline();
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Module& value, Iterator out) {
return WriteVector(ctx, value, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ScriptModule& value, Iterator out) {
out = WriteLpar(ctx, "module", out);
out = Write(ctx, value.name, out);
switch (value.kind) {
case ScriptModuleKind::Text:
ctx.Indent();
ctx.Newline();
out = Write(ctx, value.module(), out);
ctx.Dedent();
break;
case ScriptModuleKind::Binary:
out = Write(ctx, "binary"_sv, out);
out = Write(ctx, value.text_list(), out);
break;
case ScriptModuleKind::Quote:
out = Write(ctx, "quote"_sv, out);
out = Write(ctx, value.text_list(), out);
break;
}
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Const& value, Iterator out) {
out = WriteLpar(ctx, out);
switch (value.kind()) {
case ConstKind::U32:
out = Write(ctx, Opcode::I32Const, out);
out = WriteInt(ctx, value.u32_(), out);
break;
case ConstKind::U64:
out = Write(ctx, Opcode::I64Const, out);
out = WriteInt(ctx, value.u64_(), out);
break;
case ConstKind::F32:
out = Write(ctx, Opcode::F32Const, out);
out = WriteFloat(ctx, value.f32_(), out);
break;
case ConstKind::F64:
out = Write(ctx, Opcode::F64Const, out);
out = WriteFloat(ctx, value.f64_(), out);
break;
case ConstKind::V128:
out = Write(ctx, Opcode::V128Const, out);
out = Write(ctx, value.v128_(), out);
break;
case ConstKind::RefNull:
out = Write(ctx, Opcode::RefNull, out);
break;
case ConstKind::RefExtern:
out = Write(ctx, "ref.extern"_sv, out);
out = WriteNat(ctx, value.ref_extern().var, out);
break;
}
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ConstList& values, Iterator out) {
return WriteVector(ctx, values, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const InvokeAction& value, Iterator out) {
out = WriteLpar(ctx, "invoke", out);
out = Write(ctx, value.module, out);
out = Write(ctx, value.name, out);
out = Write(ctx, value.consts, out);
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const GetAction& value, Iterator out) {
out = WriteLpar(ctx, "get", out);
out = Write(ctx, value.module, out);
out = Write(ctx, value.name, out);
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Action& value, Iterator out) {
if (holds_alternative<InvokeAction>(value)) {
out = Write(ctx, get<InvokeAction>(value), out);
} else if (holds_alternative<GetAction>(value)) {
out = Write(ctx, get<GetAction>(value), out);
}
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ModuleAssertion& value, Iterator out) {
out = Write(ctx, value.module, out);
ctx.Newline();
out = Write(ctx, value.message, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ActionAssertion& value, Iterator out) {
out = Write(ctx, value.action, out);
out = Write(ctx, value.message, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const NanKind& value, Iterator out) {
if (value == NanKind::Arithmetic) {
return Write(ctx, "nan:arithmetic"_sv, out);
} else {
assert(value == NanKind::Canonical);
return Write(ctx, "nan:canonical"_sv, out);
}
}
template <typename Iterator, typename T>
Iterator Write(WriteCtx& ctx, const FloatResult<T>& value, Iterator out) {
if (holds_alternative<T>(value)) {
return WriteFloat(ctx, get<T>(value), out);
} else {
return Write(ctx, get<NanKind>(value), out);
}
}
template <typename Iterator, typename T, size_t N>
Iterator Write(WriteCtx& ctx,
const std::array<FloatResult<T>, N>& value,
Iterator out) {
return WriteRange(ctx, value.begin(), value.end(), out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ReturnResult& value, Iterator out) {
out = WriteLpar(ctx, out);
switch (static_cast<ReturnResultKind>(value.index())) {
case ReturnResultKind::U32:
out = Write(ctx, Opcode::I32Const, out);
out = WriteInt(ctx, get<u32>(value), out);
break;
case ReturnResultKind::U64:
out = Write(ctx, Opcode::I64Const, out);
out = WriteInt(ctx, get<u64>(value), out);
break;
case ReturnResultKind::V128:
out = Write(ctx, Opcode::V128Const, out);
out = Write(ctx, get<v128>(value), out);
break;
case ReturnResultKind::F32Result:
out = Write(ctx, Opcode::F32Const, out);
out = Write(ctx, get<F32Result>(value), out);
break;
case ReturnResultKind::F64Result:
out = Write(ctx, Opcode::F64Const, out);
out = Write(ctx, get<F64Result>(value), out);
break;
case ReturnResultKind::F32x4Result:
out = Write(ctx, Opcode::V128Const, out);
out = Write(ctx, "f32x4"_sv, out);
out = Write(ctx, get<F32x4Result>(value), out);
break;
case ReturnResultKind::F64x2Result:
out = Write(ctx, Opcode::V128Const, out);
out = Write(ctx, "f64x2"_sv, out);
out = Write(ctx, get<F64x2Result>(value), out);
break;
case ReturnResultKind::RefNullConst:
out = Write(ctx, Opcode::RefNull, out);
out = Write(ctx, *get<RefNullConst>(value).type, out);
break;
case ReturnResultKind::RefNullResult:
out = Write(ctx, Opcode::RefNull, out);
break;
case ReturnResultKind::RefExternConst:
out = Write(ctx, "ref.extern"_sv, out);
out = WriteNat(ctx, *get<RefExternConst>(value).var, out);
break;
case ReturnResultKind::RefExternResult:
out = Write(ctx, "ref.extern"_sv, out);
break;
case ReturnResultKind::RefFuncResult:
out = Write(ctx, "ref.func"_sv, out);
break;
}
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ReturnResultList& values, Iterator out) {
return WriteVector(ctx, values, out);
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const ReturnAssertion& value, Iterator out) {
out = Write(ctx, value.action, out);
out = Write(ctx, value.results, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Assertion& value, Iterator out) {
switch (value.kind) {
case AssertionKind::Malformed:
out = WriteLpar(ctx, "assert_malformed", out);
ctx.Indent();
ctx.Newline();
out = Write(ctx, get<ModuleAssertion>(value.desc), out);
ctx.Dedent();
break;
case AssertionKind::Invalid:
out = WriteLpar(ctx, "assert_invalid", out);
ctx.Indent();
ctx.Newline();
out = Write(ctx, get<ModuleAssertion>(value.desc), out);
ctx.Dedent();
break;
case AssertionKind::Unlinkable:
out = WriteLpar(ctx, "assert_unlinkable", out);
ctx.Indent();
ctx.Newline();
out = Write(ctx, get<ModuleAssertion>(value.desc), out);
ctx.Dedent();
break;
case AssertionKind::ActionTrap:
out = WriteLpar(ctx, "assert_trap", out);
out = Write(ctx, get<ActionAssertion>(value.desc), out);
break;
case AssertionKind::Return:
out = WriteLpar(ctx, "assert_return", out);
out = Write(ctx, get<ReturnAssertion>(value.desc), out);
break;
case AssertionKind::ModuleTrap:
out = WriteLpar(ctx, "assert_trap", out);
ctx.Indent();
ctx.Newline();
out = Write(ctx, get<ModuleAssertion>(value.desc), out);
ctx.Dedent();
break;
case AssertionKind::Exhaustion:
out = WriteLpar(ctx, "assert_exhaustion", out);
out = Write(ctx, get<ActionAssertion>(value.desc), out);
break;
}
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Register& value, Iterator out) {
out = WriteLpar(ctx, "register", out);
out = Write(ctx, value.name, out);
out = Write(ctx, value.module, out);
out = WriteRpar(ctx, out);
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Command& value, Iterator out) {
switch (value.kind()) {
case CommandKind::ScriptModule:
out = Write(ctx, value.script_module(), out);
break;
case CommandKind::Register:
out = Write(ctx, value.register_(), out);
break;
case CommandKind::Action:
out = Write(ctx, value.action(), out);
break;
case CommandKind::Assertion:
out = Write(ctx, value.assertion(), out);
break;
}
ctx.Newline();
return out;
}
template <typename Iterator>
Iterator Write(WriteCtx& ctx, const Script& values, Iterator out) {
return WriteVector(ctx, values, out);
}
} // namespace wasp::text
#endif // WASP_TEXT_WRITE_H_
| //
// Copyright 2020 WebAssembly Community Group participants
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef WASP_TEXT_WRITE_H_
#define WASP_TEXT_WRITE_H_
#include <algorithm>
#include <IMPORT_4>
#include <IMPORT_5>
#include <type_traits>
#include "wasp/base/concat.h"
#include "IMPORT_6"
#include "wasp/base/types.h"
#include "wasp/base/v128.h"
#include "wasp/text/numeric.h"
#include "IMPORT_7"
namespace VAR_151::text {
struct VAR_152 {
void ClearSeparator() { separator = ""; }
void Space() { separator = " "; }
void Newline() { separator = indent; }
void Indent() { indent += " "; }
void FUNC_2(size_t minimum) {
if (indent.size() > minimum) {
indent.FUNC_55(indent.size() - 2);
}
}
void Dedent() { FUNC_2(2); }
void DedentNoToplevel() { FUNC_2(3); }
std::IMPORT_5 separator;
std::IMPORT_5 indent = "\n";
CLASS_4 VAR_154 = VAR_153::Decimal;
};
// WriteRaw
template <typename Iterator>
Iterator WriteRaw(VAR_152& VAR_155, char VAR_156, Iterator VAR_157) {
*VAR_157++ = VAR_156;
return VAR_157;
}
template <typename Iterator>
Iterator WriteRaw(VAR_152& VAR_155, VAR_158 VAR_156, Iterator VAR_157) {
return std::copy(VAR_156.begin(), VAR_156.end(), VAR_157);
}
template <typename Iterator>
Iterator WriteRaw(VAR_152& VAR_155, VAR_159 std::IMPORT_5& VAR_156, Iterator VAR_157) {
return std::copy(VAR_156.begin(), VAR_156.end(), VAR_157);
}
template <typename Iterator>
Iterator WriteSeparator(VAR_152& VAR_155, Iterator VAR_157) {
VAR_157 = WriteRaw(VAR_155, VAR_155.separator, VAR_157);
VAR_155.ClearSeparator();
return VAR_157;
}
// WriteFormat
template <typename Iterator, typename T>
Iterator FUNC_57(VAR_152& VAR_155, VAR_159 T& VAR_156, Iterator VAR_157) {
VAR_157 = WriteSeparator(VAR_155, VAR_157);
VAR_157 = WriteRaw(VAR_155, FUNC_58(VAR_156), VAR_157);
VAR_155.Space();
return VAR_157;
}
template <typename Iterator>
Iterator WriteLpar(VAR_152& VAR_155, Iterator VAR_157) {
VAR_157 = WriteSeparator(VAR_155, VAR_157);
VAR_157 = WriteRaw(VAR_155, '(', VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator WriteLpar(VAR_152& VAR_155, VAR_158 VAR_160, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, VAR_157);
VAR_157 = WriteRaw(VAR_155, VAR_160, VAR_157);
VAR_155.Space();
return VAR_157;
}
template <typename Iterator>
Iterator WriteRpar(VAR_152& VAR_155, Iterator VAR_157) {
VAR_155.ClearSeparator();
VAR_157 = WriteRaw(VAR_155, ')', VAR_157);
VAR_155.Space();
return VAR_157;
}
template <typename Iterator, typename SourceIter>
Iterator WriteRange(VAR_152& VAR_155,
SourceIter begin,
SourceIter end,
Iterator VAR_157) {
for (auto iter = begin; iter != end; ++iter) {
VAR_157 = Write(VAR_155, *iter, VAR_157);
}
return VAR_157;
}
template <typename Iterator, typename T>
Iterator WriteVector(VAR_152& VAR_155,
VAR_159 std::vector<T>& VAR_161,
Iterator VAR_157) {
return WriteRange(VAR_155, VAR_161.begin(), VAR_161.end(), VAR_157);
}
template <typename Iterator, typename T>
Iterator Write(VAR_152& VAR_155, VAR_159 optional<T>& value_opt, Iterator VAR_157) {
if (value_opt) {
VAR_157 = Write(VAR_155, *value_opt, VAR_157);
}
return VAR_157;
}
template <typename Iterator, typename T>
Iterator Write(VAR_152& VAR_155, VAR_159 At<T>& VAR_156, Iterator VAR_157) {
return Write(VAR_155, *VAR_156, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_158 VAR_156, Iterator VAR_157) {
VAR_157 = WriteSeparator(VAR_155, VAR_157);
VAR_157 = WriteRaw(VAR_155, VAR_156, VAR_157);
VAR_155.Space();
return VAR_157;
}
template <typename Iterator, typename T>
Iterator WriteNat(VAR_152& VAR_155, VAR_159 At<T>& VAR_156, Iterator VAR_157) {
return WriteNat(VAR_155, *VAR_156, VAR_157);
}
template <typename Iterator, typename T>
Iterator FUNC_11(VAR_152& VAR_155, VAR_159 At<T>& VAR_156, Iterator VAR_157) {
return FUNC_11(VAR_155, *VAR_156, VAR_157);
}
template <typename Iterator, typename T>
Iterator WriteFloat(VAR_152& VAR_155, VAR_159 At<T>& VAR_156, Iterator VAR_157) {
return WriteFloat(VAR_155, *VAR_156, VAR_157);
}
template <typename Iterator, typename T>
Iterator WriteNat(VAR_152& VAR_155, T VAR_156, Iterator VAR_157) {
return Write(VAR_155, VAR_158{VAR_162<T>(VAR_156, VAR_155.VAR_154)}, VAR_157);
}
template <typename Iterator, typename T>
Iterator FUNC_11(VAR_152& VAR_155, T VAR_156, Iterator VAR_157) {
return Write(VAR_155, VAR_158{IntToStr<T>(VAR_156, VAR_155.VAR_154)}, VAR_157);
}
template <typename Iterator, typename T >
Iterator WriteFloat(VAR_152& VAR_155, T VAR_156, Iterator VAR_157) {
return Write(VAR_155, VAR_158{FloatToStr<T>(VAR_156, VAR_155.VAR_154)}, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, Var VAR_156, Iterator VAR_157) {
if (VAR_156.FUNC_13()) {
return WriteNat(VAR_155, VAR_156.index(), VAR_157);
} else {
return Write(VAR_155, VAR_156.FUNC_7(), VAR_157);
}
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VarList& VAR_161, Iterator VAR_157) {
return WriteVector(VAR_155, VAR_161, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_163& VAR_156, Iterator VAR_157) {
return Write(VAR_155, VAR_156.text, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 TextList& VAR_161, Iterator VAR_157) {
return WriteVector(VAR_155, VAR_161, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ValueType& VAR_156, Iterator VAR_157) {
return FUNC_57(VAR_155, VAR_156, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_164& VAR_161, Iterator VAR_157) {
return WriteVector(VAR_155, VAR_161, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155,
VAR_159 VAR_164& VAR_161,
VAR_158 VAR_160,
Iterator VAR_157) {
if (!VAR_161.empty()) {
VAR_157 = WriteLpar(VAR_155, VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_161, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_165& VAR_156, Iterator VAR_157) {
return FUNC_57(VAR_155, VAR_156, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 FieldType& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "field", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
if (VAR_156.mut == Mutability::Var) {
VAR_157 = WriteLpar(VAR_155, "mut", VAR_157);
}
VAR_157 = Write(VAR_155, VAR_156.VAR_166, VAR_157);
if (VAR_156.mut == Mutability::Var) {
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 FieldTypeList& VAR_161, Iterator VAR_157) {
bool VAR_167 = true;
bool prev_has_name = false;
for (auto& CLASS_5 : VAR_161) {
bool has_name = VAR_156->VAR_160.has_value();
if ((has_name || prev_has_name) && !VAR_167) {
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
if (has_name || prev_has_name || VAR_167) {
VAR_157 = WriteLpar(VAR_155, "field", VAR_157);
}
if (has_name) {
VAR_157 = Write(VAR_155, VAR_156->VAR_160, VAR_157);
}
if (VAR_156->mut == Mutability::Var) {
VAR_157 = WriteLpar(VAR_155, "mut", VAR_157);
}
VAR_157 = Write(VAR_155, VAR_156->VAR_166, VAR_157);
if (VAR_156->mut == Mutability::Var) {
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
prev_has_name = has_name;
VAR_167 = false;
}
if (!VAR_161.empty()) {
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_168& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "struct", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.fields, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ArrayType& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "array", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.field, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 FunctionType& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.params, "param", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.results, "result", VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator WriteTypeUse(VAR_152& VAR_155, VAR_159 OptAt<Var>& VAR_156, Iterator VAR_157) {
if (VAR_156) {
VAR_157 = WriteLpar(VAR_155, "type", VAR_157);
VAR_157 = Write(VAR_155, VAR_156->FUNC_56(), VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 FunctionTypeUse& VAR_156, Iterator VAR_157) {
VAR_157 = WriteTypeUse(VAR_155, VAR_156.type_use, VAR_157);
VAR_157 = Write(VAR_155, *VAR_156.VAR_166, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 v128& VAR_156, Iterator VAR_157) {
VAR_169 VAR_170 = VAR_156.VAR_171<VAR_169>();
VAR_157 = Write(VAR_155, "i32x4"VAR_172, VAR_157);
for (auto& lane : VAR_170) {
VAR_157 = FUNC_11(VAR_155, lane, VAR_157);
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 BlockImmediate& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.label, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_166, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_173& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, *VAR_156.parent, VAR_157);
VAR_157 = Write(VAR_155, *VAR_156.child, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_174& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, *VAR_156.target, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.types, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 BrTableImmediate& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.targets, VAR_157);
VAR_157 = Write(VAR_155, *VAR_156.VAR_175, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155,
VAR_159 VAR_176& VAR_156,
Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.VAR_177, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_166, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 CopyImmediate& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.dst, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.src, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 InitImmediate& VAR_156, Iterator VAR_157) {
// Write dst first, if it exists.
if (VAR_156.dst) {
VAR_157 = Write(VAR_155, VAR_156.dst->FUNC_56(), VAR_157);
}
VAR_157 = Write(VAR_155, *VAR_156.VAR_178, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 LetImmediate& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.VAR_179, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.locals, "local", VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 MemArgImmediate& VAR_156, Iterator VAR_157) {
if (VAR_156.memory) {
VAR_157 = Write(VAR_155, *VAR_156.memory, VAR_157);
}
if (VAR_156.offset) {
VAR_157 = Write(VAR_155, "offset="VAR_172, VAR_157);
VAR_155.ClearSeparator();
VAR_157 = WriteNat(VAR_155, VAR_156.offset->FUNC_56(), VAR_157);
}
if (VAR_156.VAR_180) {
VAR_157 = Write(VAR_155, "align="VAR_172, VAR_157);
VAR_155.ClearSeparator();
VAR_157 = WriteNat(VAR_155, VAR_156.VAR_180->FUNC_56(), VAR_157);
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 MemOptImmediate& VAR_156, Iterator VAR_157) {
if (VAR_156.memory) {
VAR_157 = Write(VAR_155, *VAR_156.memory, VAR_157);
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 RttSubImmediate& VAR_156, Iterator VAR_157) {
VAR_157 = WriteNat(VAR_155, *VAR_156.depth, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.types, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ShuffleImmediate& VAR_156, Iterator VAR_157) {
for (auto& lane : VAR_156) {
VAR_157 = WriteNat(VAR_155, lane, VAR_157);
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 StructFieldImmediate& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, *VAR_156.struct_, VAR_157);
VAR_157 = Write(VAR_155, *VAR_156.field, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155,
VAR_159 SimdMemoryLaneImmediate& VAR_156,
Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.VAR_181, VAR_157);
VAR_157 = WriteNat(VAR_155, *VAR_156.lane, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 Opcode& VAR_156, Iterator VAR_157) {
return FUNC_57(VAR_155, VAR_156, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 Instruction& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, *VAR_156.opcode, VAR_157);
switch (VAR_156.kind()) {
case InstructionKind::VAR_182:
break;
case InstructionKind::S32:
VAR_157 = FUNC_11(VAR_155, VAR_156.FUNC_18(), VAR_157);
break;
case InstructionKind::S64:
VAR_157 = FUNC_11(VAR_155, VAR_156.s64_immediate(), VAR_157);
break;
case InstructionKind::VAR_183:
VAR_157 = WriteFloat(VAR_155, VAR_156.f32_immediate(), VAR_157);
break;
case InstructionKind::F64:
VAR_157 = WriteFloat(VAR_155, VAR_156.FUNC_21(), VAR_157);
break;
case InstructionKind::VAR_184:
VAR_157 = Write(VAR_155, VAR_156.FUNC_60(), VAR_157);
break;
case InstructionKind::Var:
VAR_157 = Write(VAR_155, VAR_156.var_immediate(), VAR_157);
break;
case InstructionKind::Block:
VAR_157 = Write(VAR_155, VAR_156.block_immediate(), VAR_157);
break;
case InstructionKind::VAR_185:
VAR_157 = Write(VAR_155, VAR_156.br_table_immediate(), VAR_157);
break;
case InstructionKind::CallIndirect:
VAR_157 = Write(VAR_155, VAR_156.call_indirect_immediate(), VAR_157);
break;
case InstructionKind::Copy:
VAR_157 = Write(VAR_155, VAR_156.copy_immediate(), VAR_157);
break;
case InstructionKind::Init:
VAR_157 = Write(VAR_155, VAR_156.FUNC_61(), VAR_157);
break;
case InstructionKind::Let:
VAR_157 = Write(VAR_155, VAR_156.let_immediate(), VAR_157);
break;
case InstructionKind::MemArg:
VAR_157 = Write(VAR_155, VAR_156.mem_arg_immediate(), VAR_157);
break;
case InstructionKind::MemOpt:
VAR_157 = Write(VAR_155, VAR_156.mem_opt_immediate(), VAR_157);
break;
case InstructionKind::VAR_186:
VAR_157 = Write(VAR_155, VAR_156.heap_type_immediate(), VAR_157);
break;
case InstructionKind::VAR_187:
VAR_157 = Write(VAR_155, VAR_156.select_immediate(), VAR_157);
break;
case InstructionKind::Shuffle:
VAR_157 = Write(VAR_155, VAR_156.shuffle_immediate(), VAR_157);
break;
case InstructionKind::VAR_188:
VAR_157 = WriteNat(VAR_155, VAR_156.FUNC_62(), VAR_157);
break;
case InstructionKind::SimdMemoryLane:
VAR_157 = Write(VAR_155, VAR_156.simd_memory_lane_immediate(), VAR_157);
break;
case InstructionKind::VAR_189:
VAR_157 = Write(VAR_155, VAR_156.func_bind_immediate(), VAR_157);
break;
case InstructionKind::BrOnCast:
VAR_157 = Write(VAR_155, VAR_156.FUNC_63(), VAR_157);
break;
case InstructionKind::HeapType2:
VAR_157 = Write(VAR_155, VAR_156.heap_type_2_immediate(), VAR_157);
break;
case InstructionKind::RttSub:
VAR_157 = Write(VAR_155, VAR_156.rtt_sub_immediate(), VAR_157);
break;
case InstructionKind::VAR_190:
VAR_157 = Write(VAR_155, VAR_156.FUNC_64(), VAR_157);
break;
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_191& VAR_161, Iterator VAR_157) {
return WriteVector(VAR_155, VAR_161, VAR_157);
}
template <typename Iterator>
Iterator WriteWithNewlines(VAR_152& VAR_155,
VAR_159 VAR_191& VAR_161,
Iterator VAR_157) {
// If the instruction list ends with and `end` instruction, don't write it
// (it's implicit in the function definition, in the text format.)
span<VAR_159 At<Instruction>> instrs{VAR_161};
if (!VAR_161.empty() && VAR_161.back()->opcode == Opcode::VAR_192) {
instrs.remove_suffix(1);
}
for (auto& instr : instrs) {
auto opcode = instr->opcode;
if (opcode == Opcode::VAR_192 || opcode == Opcode::Else ||
opcode == Opcode::Catch || opcode == Opcode::VAR_193 ||
opcode == Opcode::Delegate) {
VAR_155.DedentNoToplevel();
VAR_155.Newline();
}
VAR_157 = Write(VAR_155, instr, VAR_157);
if (instr->has_block_immediate() || instr->has_let_immediate() ||
opcode == Opcode::Else || opcode == Opcode::Catch ||
opcode == Opcode::VAR_193) {
VAR_155.Indent();
}
VAR_155.Newline();
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_194& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_166, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155,
VAR_159 BoundValueTypeList& VAR_161,
VAR_158 prefix,
Iterator VAR_157) {
bool VAR_167 = true;
bool prev_has_name = false;
for (auto& CLASS_5 : VAR_161) {
bool has_name = VAR_156->VAR_160.has_value();
if ((has_name || prev_has_name) && !VAR_167) {
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
if (has_name || prev_has_name || VAR_167) {
VAR_157 = WriteLpar(VAR_155, prefix, VAR_157);
}
if (has_name) {
VAR_157 = Write(VAR_155, VAR_156->VAR_160, VAR_157);
}
VAR_157 = Write(VAR_155, VAR_156->VAR_166, VAR_157);
prev_has_name = has_name;
VAR_167 = false;
}
if (!VAR_161.empty()) {
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 BoundFunctionType& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.params, "param", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.results, "result", VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 DefinedType& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "type", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
if (VAR_156.is_function_type()) {
VAR_157 = WriteLpar(VAR_155, "func", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.function_type(), VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
} else if (VAR_156.FUNC_36()) {
VAR_157 = Write(VAR_155, VAR_156.struct_type(), VAR_157);
} else {
assert(VAR_156.is_array_type());
VAR_157 = Write(VAR_155, VAR_156.array_type(), VAR_157);
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 FunctionDesc& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, "func"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = WriteTypeUse(VAR_155, VAR_156.type_use, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_166, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 Limits& VAR_156, Iterator VAR_157) {
if (VAR_156.index_type == IndexType::I64) {
VAR_157 = Write(VAR_155, "i64"VAR_172, VAR_157);
}
VAR_157 = WriteNat(VAR_155, VAR_156.min, VAR_157);
if (VAR_156.VAR_195) {
VAR_157 = WriteNat(VAR_155, *VAR_156.VAR_195, VAR_157);
}
if (VAR_156.shared == Shared::Yes) {
VAR_157 = Write(VAR_155, "shared"VAR_172, VAR_157);
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_186 VAR_156, Iterator VAR_157) {
return FUNC_57(VAR_155, VAR_156, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, ReferenceType VAR_156, Iterator VAR_157) {
return FUNC_57(VAR_155, VAR_156, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 Rtt& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "rtt", VAR_157);
VAR_157 = WriteNat(VAR_155, VAR_156.depth, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_166, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_196& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.limits, VAR_157);
VAR_157 = FUNC_57(VAR_155, VAR_156.elemtype, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 TableDesc& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, "table"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_166, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 MemoryType& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.limits, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 MemoryDesc& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, "memory"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_166, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_197& VAR_156, Iterator VAR_157) {
if (VAR_156.mut == Mutability::Var) {
VAR_157 = WriteLpar(VAR_155, "mut", VAR_157);
}
VAR_157 = Write(VAR_155, VAR_156.valtype, VAR_157);
if (VAR_156.mut == Mutability::Var) {
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 GlobalDesc& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, "global"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_166, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_198& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.VAR_166, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 TagDesc& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, "tag"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_166, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_199& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "import"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_200, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = WriteLpar(VAR_155, VAR_157);
switch (VAR_156.kind()) {
case ExternalKind::Function:
VAR_157 = Write(VAR_155, VAR_156.function_desc(), VAR_157);
break;
case ExternalKind::Table:
VAR_157 = Write(VAR_155, VAR_156.table_desc(), VAR_157);
break;
case ExternalKind::Memory:
VAR_157 = Write(VAR_155, VAR_156.memory_desc(), VAR_157);
break;
case ExternalKind::VAR_201:
VAR_157 = Write(VAR_155, VAR_156.global_desc(), VAR_157);
break;
case ExternalKind::VAR_202:
VAR_157 = Write(VAR_155, VAR_156.tag_desc(), VAR_157);
break;
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 InlineImport& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "import"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_200, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 InlineExport& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "export"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 InlineExportList& VAR_161, Iterator VAR_157) {
return WriteVector(VAR_155, VAR_161, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 Function& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "func", VAR_157);
// Can't write FunctionDesc directly, since inline imports/exports occur
// between the bindvar and the type use.
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.exports, VAR_157);
if (VAR_156.import) {
VAR_157 = Write(VAR_155, *VAR_156.import, VAR_157);
}
VAR_157 = WriteTypeUse(VAR_155, VAR_156.desc.type_use, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_166, VAR_157);
if (!VAR_156.import) {
VAR_155.Indent();
VAR_155.Newline();
VAR_157 = Write(VAR_155, VAR_156.locals, "local", VAR_157);
VAR_155.Newline();
VAR_157 = WriteWithNewlines(VAR_155, VAR_156.instructions, VAR_157);
VAR_155.Dedent();
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
VAR_155.Newline();
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155,
VAR_159 ElementExpressionList& VAR_203,
Iterator VAR_157) {
// Use spaces instead of newlines for element expressions.
for (auto& VAR_204 : VAR_203) {
for (auto& instr : VAR_204->instructions) {
// Expressions need to be wrapped in parens.
VAR_157 = WriteLpar(VAR_155, VAR_157);
VAR_157 = Write(VAR_155, instr, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
VAR_155.Space();
}
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155,
VAR_159 VAR_205& VAR_156,
Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.elemtype, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_206, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, ExternalKind VAR_156, Iterator VAR_157) {
return FUNC_57(VAR_155, VAR_156, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ElementListWithVars& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.kind, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_206, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_207& VAR_156, Iterator VAR_157) {
if (VAR_208<ElementListWithVars>(VAR_156)) {
return Write(VAR_155, VAR_209<ElementListWithVars>(VAR_156), VAR_157);
} else {
return Write(VAR_155, VAR_209<VAR_205>(VAR_156), VAR_157);
}
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 Table& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "table", VAR_157);
// Can't write TableDesc directly, since inline imports/exports occur after
// the bind var.
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.exports, VAR_157);
if (VAR_156.import) {
VAR_157 = Write(VAR_155, *VAR_156.import, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_166, VAR_157);
} else if (VAR_156.elements) {
// Don't write the limits, because they are implicitly defined by the
// element segment length.
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_166->elemtype, VAR_157);
VAR_157 = WriteLpar(VAR_155, "elem", VAR_157);
// Only write the list of elements, without the ExternalKind or
// ReferenceType.
if (VAR_208<ElementListWithVars>(*VAR_156.elements)) {
VAR_157 = Write(VAR_155, VAR_209<ElementListWithVars>(*VAR_156.elements).VAR_206, VAR_157);
} else {
VAR_157 = Write(VAR_155,
VAR_209<VAR_205>(*VAR_156.elements).VAR_206, VAR_157);
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
} else {
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_166, VAR_157);
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename T, typename Iterator>
Iterator WriteNumericValues(VAR_152& VAR_155,
VAR_159 NumericData& VAR_156,
Iterator VAR_157) {
for (Index i = 0; i < VAR_156.FUNC_43(); ++i) {
if constexpr (std::is_same_v<T, v128>) {
VAR_157 = Write(VAR_155, VAR_156.VAR_156<T>(i), VAR_157);
} else if constexpr (std::is_floating_point_v<T>) {
VAR_157 = WriteFloat(VAR_155, VAR_156.VAR_156<T>(i), VAR_157);
} else {
VAR_157 = FUNC_11(VAR_155, VAR_156.VAR_156<T>(i), VAR_157);
}
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 NumericData& VAR_156, Iterator VAR_157) {
switch (VAR_156.VAR_166) {
case NumericDataType::I8:
VAR_157 = WriteLpar(VAR_155, "i8", VAR_157);
VAR_157 = WriteNumericValues<s8>(VAR_155, VAR_156, VAR_157);
break;
case NumericDataType::I16:
VAR_157 = WriteLpar(VAR_155, "i16", VAR_157);
VAR_157 = WriteNumericValues<VAR_210>(VAR_155, VAR_156, VAR_157);
break;
case NumericDataType::I32:
VAR_157 = WriteLpar(VAR_155, "i32", VAR_157);
VAR_157 = WriteNumericValues<VAR_211>(VAR_155, VAR_156, VAR_157);
break;
case NumericDataType::I64:
VAR_157 = WriteLpar(VAR_155, "i64", VAR_157);
VAR_157 = WriteNumericValues<s64>(VAR_155, VAR_156, VAR_157);
break;
case NumericDataType::F32:
VAR_157 = WriteLpar(VAR_155, "f32", VAR_157);
VAR_157 = WriteNumericValues<f32>(VAR_155, VAR_156, VAR_157);
break;
case NumericDataType::F64:
VAR_157 = WriteLpar(VAR_155, "f64", VAR_157);
VAR_157 = WriteNumericValues<VAR_212>(VAR_155, VAR_156, VAR_157);
break;
case NumericDataType::V128:
VAR_157 = WriteLpar(VAR_155, "v128", VAR_157);
VAR_157 = WriteNumericValues<v128>(VAR_155, VAR_156, VAR_157);
break;
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 DataItem& VAR_156, Iterator VAR_157) {
if (VAR_156.FUNC_44()) {
return Write(VAR_155, VAR_156.text(), VAR_157);
} else {
assert(VAR_156.is_numeric_data());
return Write(VAR_155, VAR_156.numeric_data(), VAR_157);
}
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 DataItemList& VAR_161, Iterator VAR_157) {
return WriteVector(VAR_155, VAR_161, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 Memory& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "memory", VAR_157);
// Can't write MemoryDesc directly, since inline imports/exports occur after
// the bind var.
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.exports, VAR_157);
if (VAR_156.import) {
VAR_157 = Write(VAR_155, *VAR_156.import, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_166, VAR_157);
} else if (VAR_156.VAR_213) {
VAR_157 = WriteLpar(VAR_155, "data", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_213, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
} else {
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_166, VAR_157);
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_214& VAR_156, Iterator VAR_157) {
return Write(VAR_155, VAR_156.instructions, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_201& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "global", VAR_157);
// Can't write GlobalDesc directly, since inline imports/exports occur after
// the bind var.
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.exports, VAR_157);
if (VAR_156.import) {
VAR_157 = Write(VAR_155, *VAR_156.import, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_166, VAR_157);
} else {
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_166, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.init, VAR_157);
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 Export& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "export", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = WriteLpar(VAR_155, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.kind, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_215, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 Start& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "start", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_215, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ElementExpression& VAR_156, Iterator VAR_157) {
return Write(VAR_155, VAR_156.instructions, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ElementSegment& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "elem", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
switch (VAR_156.VAR_166) {
case SegmentType::Active:
if (VAR_156.VAR_177) {
VAR_157 = WriteLpar(VAR_155, "table", VAR_157);
VAR_157 = Write(VAR_155, *VAR_156.VAR_177, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
if (VAR_156.offset) {
VAR_157 = WriteLpar(VAR_155, "offset", VAR_157);
VAR_157 = Write(VAR_155, *VAR_156.offset, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
// When writing a function var list, we can omit the "func" keyword to
// remain compatible with the MVP text format.
if (VAR_208<ElementListWithVars>(VAR_156.elements)) {
auto& element_vars = VAR_209<ElementListWithVars>(VAR_156.elements);
// The legacy format which omits the external kind cannot be used with
// the "table use" or bind_var syntax.
if (element_vars.kind != ExternalKind::Function || VAR_156.VAR_177 ||
VAR_156.VAR_160) {
VAR_157 = Write(VAR_155, element_vars.kind, VAR_157);
}
VAR_157 = Write(VAR_155, element_vars.VAR_206, VAR_157);
} else {
VAR_157 = Write(VAR_155, VAR_209<VAR_205>(VAR_156.elements), VAR_157);
}
break;
case SegmentType::Passive:
VAR_157 = Write(VAR_155, VAR_156.elements, VAR_157);
break;
case SegmentType::VAR_216:
VAR_157 = Write(VAR_155, "declare"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.elements, VAR_157);
break;
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 DataSegment& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "data", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
if (VAR_156.VAR_166 == SegmentType::Active) {
if (VAR_156.memory) {
VAR_157 = WriteLpar(VAR_155, "memory", VAR_157);
VAR_157 = Write(VAR_155, *VAR_156.memory, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
if (VAR_156.offset) {
VAR_157 = WriteLpar(VAR_155, "offset", VAR_157);
VAR_157 = Write(VAR_155, *VAR_156.offset, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
}
}
VAR_157 = Write(VAR_155, VAR_156.VAR_213, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_202& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "tag", VAR_157);
// Can't write TagDesc directly, since inline imports/exports occur after
// the bind var.
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.exports, VAR_157);
if (VAR_156.import) {
VAR_157 = Write(VAR_155, *VAR_156.import, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_166, VAR_157);
} else {
VAR_157 = Write(VAR_155, VAR_156.desc.VAR_166, VAR_157);
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ModuleItem& VAR_156, Iterator VAR_157) {
switch (VAR_156.kind()) {
case ModuleItemKind::DefinedType:
VAR_157 = Write(VAR_155, VAR_156.FUNC_65(), VAR_157);
break;
case ModuleItemKind::VAR_199:
VAR_157 = Write(VAR_155, VAR_156.import(), VAR_157);
break;
case ModuleItemKind::Function:
VAR_157 = Write(VAR_155, VAR_156.function(), VAR_157);
break;
case ModuleItemKind::Table:
VAR_157 = Write(VAR_155, VAR_156.FUNC_59(), VAR_157);
break;
case ModuleItemKind::Memory:
VAR_157 = Write(VAR_155, VAR_156.memory(), VAR_157);
break;
case ModuleItemKind::VAR_201:
VAR_157 = Write(VAR_155, VAR_156.global(), VAR_157);
break;
case ModuleItemKind::Export:
VAR_157 = Write(VAR_155, VAR_156.export_(), VAR_157);
break;
case ModuleItemKind::Start:
VAR_157 = Write(VAR_155, VAR_156.FUNC_48(), VAR_157);
break;
case ModuleItemKind::ElementSegment:
VAR_157 = Write(VAR_155, VAR_156.element_segment(), VAR_157);
break;
case ModuleItemKind::DataSegment:
VAR_157 = Write(VAR_155, VAR_156.data_segment(), VAR_157);
break;
case ModuleItemKind::VAR_202:
VAR_157 = Write(VAR_155, VAR_156.FUNC_51(), VAR_157);
break;
}
VAR_155.Newline();
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 Module& VAR_156, Iterator VAR_157) {
return WriteVector(VAR_155, VAR_156, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ScriptModule& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "module", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
switch (VAR_156.kind) {
case VAR_217::VAR_163:
VAR_155.Indent();
VAR_155.Newline();
VAR_157 = Write(VAR_155, VAR_156.FUNC_39(), VAR_157);
VAR_155.Dedent();
break;
case VAR_217::VAR_218:
VAR_157 = Write(VAR_155, "binary"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.text_list(), VAR_157);
break;
case VAR_217::Quote:
VAR_157 = Write(VAR_155, "quote"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.text_list(), VAR_157);
break;
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_219& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, VAR_157);
switch (VAR_156.kind()) {
case ConstKind::U32:
VAR_157 = Write(VAR_155, Opcode::I32Const, VAR_157);
VAR_157 = FUNC_11(VAR_155, VAR_156.FUNC_66(), VAR_157);
break;
case ConstKind::VAR_220:
VAR_157 = Write(VAR_155, Opcode::I64Const, VAR_157);
VAR_157 = FUNC_11(VAR_155, VAR_156.FUNC_53(), VAR_157);
break;
case ConstKind::VAR_183:
VAR_157 = Write(VAR_155, Opcode::VAR_221, VAR_157);
VAR_157 = WriteFloat(VAR_155, VAR_156.f32_(), VAR_157);
break;
case ConstKind::F64:
VAR_157 = Write(VAR_155, Opcode::F64Const, VAR_157);
VAR_157 = WriteFloat(VAR_155, VAR_156.f64_(), VAR_157);
break;
case ConstKind::VAR_184:
VAR_157 = Write(VAR_155, Opcode::V128Const, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.FUNC_67(), VAR_157);
break;
case ConstKind::VAR_222:
VAR_157 = Write(VAR_155, Opcode::VAR_222, VAR_157);
break;
case ConstKind::VAR_223:
VAR_157 = Write(VAR_155, "ref.extern"VAR_172, VAR_157);
VAR_157 = WriteNat(VAR_155, VAR_156.FUNC_68().VAR_215, VAR_157);
break;
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ConstList& VAR_161, Iterator VAR_157) {
return WriteVector(VAR_155, VAR_161, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 InvokeAction& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "invoke", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_200, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.consts, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 GetAction& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "get", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_200, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 Action& VAR_156, Iterator VAR_157) {
if (VAR_208<InvokeAction>(VAR_156)) {
VAR_157 = Write(VAR_155, VAR_209<InvokeAction>(VAR_156), VAR_157);
} else if (VAR_208<GetAction>(VAR_156)) {
VAR_157 = Write(VAR_155, VAR_209<GetAction>(VAR_156), VAR_157);
}
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ModuleAssertion& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.VAR_200, VAR_157);
VAR_155.Newline();
VAR_157 = Write(VAR_155, VAR_156.message, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ActionAssertion& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.VAR_224, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.message, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 NanKind& VAR_156, Iterator VAR_157) {
if (VAR_156 == NanKind::Arithmetic) {
return Write(VAR_155, "nan:arithmetic"VAR_172, VAR_157);
} else {
assert(VAR_156 == NanKind::VAR_225);
return Write(VAR_155, "nan:canonical"VAR_172, VAR_157);
}
}
template <typename Iterator, typename T>
Iterator Write(VAR_152& VAR_155, VAR_159 FloatResult<T>& VAR_156, Iterator VAR_157) {
if (VAR_208<T>(VAR_156)) {
return WriteFloat(VAR_155, VAR_209<T>(VAR_156), VAR_157);
} else {
return Write(VAR_155, VAR_209<NanKind>(VAR_156), VAR_157);
}
}
template <typename Iterator, typename T, size_t VAR_226>
Iterator Write(VAR_152& VAR_155,
VAR_159 std::array<FloatResult<T>, VAR_226>& VAR_156,
Iterator VAR_157) {
return WriteRange(VAR_155, VAR_156.begin(), VAR_156.end(), VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_227& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, VAR_157);
switch (VAR_228<VAR_229>(VAR_156.index())) {
case VAR_229::U32:
VAR_157 = Write(VAR_155, Opcode::I32Const, VAR_157);
VAR_157 = FUNC_11(VAR_155, VAR_209<u32>(VAR_156), VAR_157);
break;
case VAR_229::U64:
VAR_157 = Write(VAR_155, Opcode::I64Const, VAR_157);
VAR_157 = FUNC_11(VAR_155, VAR_209<u64>(VAR_156), VAR_157);
break;
case VAR_229::V128:
VAR_157 = Write(VAR_155, Opcode::V128Const, VAR_157);
VAR_157 = Write(VAR_155, VAR_209<v128>(VAR_156), VAR_157);
break;
case VAR_229::F32Result:
VAR_157 = Write(VAR_155, Opcode::VAR_221, VAR_157);
VAR_157 = Write(VAR_155, VAR_209<F32Result>(VAR_156), VAR_157);
break;
case VAR_229::F64Result:
VAR_157 = Write(VAR_155, Opcode::F64Const, VAR_157);
VAR_157 = Write(VAR_155, VAR_209<F64Result>(VAR_156), VAR_157);
break;
case VAR_229::F32x4Result:
VAR_157 = Write(VAR_155, Opcode::V128Const, VAR_157);
VAR_157 = Write(VAR_155, "f32x4"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_209<F32x4Result>(VAR_156), VAR_157);
break;
case VAR_229::F64x2Result:
VAR_157 = Write(VAR_155, Opcode::V128Const, VAR_157);
VAR_157 = Write(VAR_155, "f64x2"VAR_172, VAR_157);
VAR_157 = Write(VAR_155, VAR_209<F64x2Result>(VAR_156), VAR_157);
break;
case VAR_229::RefNullConst:
VAR_157 = Write(VAR_155, Opcode::VAR_222, VAR_157);
VAR_157 = Write(VAR_155, *VAR_209<VAR_230>(VAR_156).VAR_166, VAR_157);
break;
case VAR_229::RefNullResult:
VAR_157 = Write(VAR_155, Opcode::VAR_222, VAR_157);
break;
case VAR_229::RefExternConst:
VAR_157 = Write(VAR_155, "ref.extern"VAR_172, VAR_157);
VAR_157 = WriteNat(VAR_155, *VAR_209<RefExternConst>(VAR_156).VAR_215, VAR_157);
break;
case VAR_229::RefExternResult:
VAR_157 = Write(VAR_155, "ref.extern"VAR_172, VAR_157);
break;
case VAR_229::RefFuncResult:
VAR_157 = Write(VAR_155, "ref.func"VAR_172, VAR_157);
break;
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ReturnResultList& VAR_161, Iterator VAR_157) {
return WriteVector(VAR_155, VAR_161, VAR_157);
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 ReturnAssertion& VAR_156, Iterator VAR_157) {
VAR_157 = Write(VAR_155, VAR_156.VAR_224, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.results, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_231& VAR_156, Iterator VAR_157) {
switch (VAR_156.kind) {
case VAR_232::Malformed:
VAR_157 = WriteLpar(VAR_155, "assert_malformed", VAR_157);
VAR_155.Indent();
VAR_155.Newline();
VAR_157 = Write(VAR_155, VAR_209<ModuleAssertion>(VAR_156.desc), VAR_157);
VAR_155.Dedent();
break;
case VAR_232::Invalid:
VAR_157 = WriteLpar(VAR_155, "assert_invalid", VAR_157);
VAR_155.Indent();
VAR_155.Newline();
VAR_157 = Write(VAR_155, VAR_209<ModuleAssertion>(VAR_156.desc), VAR_157);
VAR_155.Dedent();
break;
case VAR_232::Unlinkable:
VAR_157 = WriteLpar(VAR_155, "assert_unlinkable", VAR_157);
VAR_155.Indent();
VAR_155.Newline();
VAR_157 = Write(VAR_155, VAR_209<ModuleAssertion>(VAR_156.desc), VAR_157);
VAR_155.Dedent();
break;
case VAR_232::ActionTrap:
VAR_157 = WriteLpar(VAR_155, "assert_trap", VAR_157);
VAR_157 = Write(VAR_155, VAR_209<ActionAssertion>(VAR_156.desc), VAR_157);
break;
case VAR_232::Return:
VAR_157 = WriteLpar(VAR_155, "assert_return", VAR_157);
VAR_157 = Write(VAR_155, VAR_209<ReturnAssertion>(VAR_156.desc), VAR_157);
break;
case VAR_232::ModuleTrap:
VAR_157 = WriteLpar(VAR_155, "assert_trap", VAR_157);
VAR_155.Indent();
VAR_155.Newline();
VAR_157 = Write(VAR_155, VAR_209<ModuleAssertion>(VAR_156.desc), VAR_157);
VAR_155.Dedent();
break;
case VAR_232::Exhaustion:
VAR_157 = WriteLpar(VAR_155, "assert_exhaustion", VAR_157);
VAR_157 = Write(VAR_155, VAR_209<ActionAssertion>(VAR_156.desc), VAR_157);
break;
}
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_233& VAR_156, Iterator VAR_157) {
VAR_157 = WriteLpar(VAR_155, "register", VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_160, VAR_157);
VAR_157 = Write(VAR_155, VAR_156.VAR_200, VAR_157);
VAR_157 = WriteRpar(VAR_155, VAR_157);
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_234& VAR_156, Iterator VAR_157) {
switch (VAR_156.kind()) {
case VAR_235::ScriptModule:
VAR_157 = Write(VAR_155, VAR_156.script_module(), VAR_157);
break;
case VAR_235::Register:
VAR_157 = Write(VAR_155, VAR_156.FUNC_70(), VAR_157);
break;
case VAR_235::Action:
VAR_157 = Write(VAR_155, VAR_156.FUNC_69(), VAR_157);
break;
case VAR_235::Assertion:
VAR_157 = Write(VAR_155, VAR_156.assertion(), VAR_157);
break;
}
VAR_155.Newline();
return VAR_157;
}
template <typename Iterator>
Iterator Write(VAR_152& VAR_155, VAR_159 VAR_236& VAR_161, Iterator VAR_157) {
return WriteVector(VAR_155, VAR_161, VAR_157);
}
} // namespace wasp::text
#endif // WASP_TEXT_WRITE_H_
| 0.637671 | {'IMPORT_4': 'cassert', 'IMPORT_5': 'string', 'IMPORT_6': 'wasp/base/formatters.h', 'IMPORT_7': 'wasp/text/types.h', 'VAR_151': 'wasp', 'VAR_152': 'WriteCtx', 'FUNC_2': 'DedentWithMinimum', 'FUNC_55': 'erase', 'CLASS_4': 'Base', 'VAR_153': 'Base', 'VAR_154': 'base', 'VAR_155': 'ctx', 'VAR_156': 'value', 'CLASS_5': 'value', 'FUNC_56': 'value', 'VAR_157': 'out', 'VAR_158': 'string_view', 'VAR_159': 'const', 'FUNC_57': 'WriteFormat', 'FUNC_58': 'concat', 'VAR_160': 'name', 'FUNC_7': 'name', 'VAR_161': 'values', 'FUNC_11': 'WriteInt', 'VAR_162': 'NatToStr', 'FUNC_13': 'is_index', 'VAR_163': 'Text', 'VAR_164': 'ValueTypeList', 'VAR_165': 'StorageType', 'VAR_166': 'type', 'VAR_167': 'first', 'VAR_168': 'StructType', 'VAR_169': 'u32x4', 'VAR_170': 'immediate', 'VAR_171': 'as', 'VAR_172': '_sv', 'VAR_173': 'HeapType2Immediate', 'VAR_174': 'BrOnCastImmediate', 'VAR_175': 'default_target', 'VAR_176': 'CallIndirectImmediate', 'VAR_177': 'table', 'FUNC_59': 'table', 'VAR_178': 'segment', 'VAR_179': 'block', 'VAR_180': 'align', 'VAR_181': 'memarg', 'VAR_182': 'None', 'FUNC_18': 's32_immediate', 'VAR_183': 'F32', 'FUNC_21': 'f64_immediate', 'VAR_184': 'V128', 'FUNC_60': 'v128_immediate', 'VAR_185': 'BrTable', 'FUNC_61': 'init_immediate', 'VAR_186': 'HeapType', 'VAR_187': 'Select', 'VAR_188': 'SimdLane', 'FUNC_62': 'simd_lane_immediate', 'VAR_189': 'FuncBind', 'FUNC_63': 'br_on_cast_immediate', 'VAR_190': 'StructField', 'FUNC_64': 'struct_field_immediate', 'VAR_191': 'InstructionList', 'VAR_192': 'End', 'VAR_193': 'CatchAll', 'VAR_194': 'BoundValueType', 'FUNC_36': 'is_struct_type', 'VAR_195': 'max', 'VAR_196': 'TableType', 'VAR_197': 'GlobalType', 'VAR_198': 'TagType', 'VAR_199': 'Import', 'VAR_200': 'module', 'FUNC_39': 'module', 'VAR_201': 'Global', 'VAR_202': 'Tag', 'VAR_203': 'elem_exprs', 'VAR_204': 'elem_expr', 'VAR_205': 'ElementListWithExpressions', 'VAR_206': 'list', 'VAR_207': 'ElementList', 'VAR_208': 'holds_alternative', 'VAR_209': 'get', 'FUNC_43': 'count', 'VAR_210': 's16', 'VAR_211': 's32', 'VAR_212': 'f64', 'FUNC_44': 'is_text', 'VAR_213': 'data', 'VAR_214': 'ConstantExpression', 'VAR_215': 'var', 'VAR_216': 'Declared', 'FUNC_65': 'defined_type', 'FUNC_48': 'start', 'FUNC_51': 'tag', 'VAR_217': 'ScriptModuleKind', 'VAR_218': 'Binary', 'VAR_219': 'Const', 'FUNC_66': 'u32_', 'VAR_220': 'U64', 'FUNC_53': 'u64_', 'VAR_221': 'F32Const', 'FUNC_67': 'v128_', 'VAR_222': 'RefNull', 'VAR_223': 'RefExtern', 'FUNC_68': 'ref_extern', 'VAR_224': 'action', 'FUNC_69': 'action', 'VAR_225': 'Canonical', 'VAR_226': 'N', 'VAR_227': 'ReturnResult', 'VAR_228': 'static_cast', 'VAR_229': 'ReturnResultKind', 'VAR_230': 'RefNullConst', 'VAR_231': 'Assertion', 'VAR_232': 'AssertionKind', 'VAR_233': 'Register', 'VAR_234': 'Command', 'VAR_235': 'CommandKind', 'FUNC_70': 'register_', 'VAR_236': 'Script'} |
#pragma once
namespace Cool {
/**
* @brief Color stored as 4 unsigned chars representing Red, Green, Blue and Alpha channels
*
*/
class Color {
public:
/**
* @brief Initialized as black with 255 alpha : (0, 0, 0, 255)
*
*/
Color();
/**
* @brief Takes values in the range [0, 255] (values outside will wrap)
*
* @param r
* @param g
* @param b
*/
void set(unsigned char r, unsigned char g, unsigned char b);
/**
* @brief Takes values in the range [0, 1] (values outside are clamped to 0 or 1)
*
* @param r
* @param g
* @param b
*/
void set(float r, float g, float b);
/**
* @brief Takes values in the range [0, 1] (values outside are clamped to 0 or 1)
*
* @param color
*/
inline void set(const glm::vec3& color) { set(color.r, color.g, color.b); }
private:
unsigned char _channels[4];
};
} // namespace Cool | #pragma once
CLASS_0 VAR_0 {
/**
* @brief Color stored as 4 unsigned chars representing Red, Green, Blue and Alpha channels
*
*/
CLASS_1 Color {
public:
/**
* @brief Initialized as black with 255 alpha : (0, 0, 0, 255)
*
*/
Color();
/**
* @brief Takes values in the range [0, 255] (values outside will wrap)
*
* @param r
* @param g
* @param b
*/
void FUNC_0(unsigned char VAR_1, unsigned char VAR_2, unsigned char VAR_3);
/**
* @brief Takes values in the range [0, 1] (values outside are clamped to 0 or 1)
*
* @param r
* @param g
* @param b
*/
void FUNC_0(float VAR_1, float VAR_2, float VAR_3);
/**
* @brief Takes values in the range [0, 1] (values outside are clamped to 0 or 1)
*
* @param color
*/
inline void FUNC_0(const CLASS_2::VAR_4& color) { FUNC_0(color.VAR_1, color.VAR_2, color.VAR_3); }
private:
unsigned char VAR_5[4];
};
} // namespace Cool | 0.758772 | {'CLASS_0': 'namespace', 'VAR_0': 'Cool', 'CLASS_1': 'class', 'FUNC_0': 'set', 'VAR_1': 'r', 'VAR_2': 'g', 'VAR_3': 'b', 'CLASS_2': 'glm', 'VAR_4': 'vec3', 'VAR_5': '_channels'} |
//
// UIView+FCFrame.h
//
//
// Created by Charles on 16/9/1.
// Copyright © 2016年 Charles. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (FCFrame)
/**
* 快速根据xib创建View
*/
+ (instancetype)fc_viewFromXib;
/**
* 判断self和view是否重叠
*/
- (BOOL)fc_intersectsWithView:(UIView *)view;
/**
* 起点x坐标
*/
@property (nonatomic, assign) CGFloat fc_x;
/**
* 起点y坐标
*/
@property (nonatomic, assign) CGFloat fc_y;
/**
* 中心点x坐标
*/
@property (nonatomic, assign) CGFloat fc_centerX;
/**
* 中心点y坐标
*/
@property (nonatomic, assign) CGFloat fc_centerY;
/**
* 宽度
*/
@property (nonatomic, assign) CGFloat fc_width;
/**
* 高度
*/
@property (nonatomic, assign) CGFloat fc_height;
/**
* 顶部
*/
@property (nonatomic, assign) CGFloat fc_top;
/**
* 底部
*/
@property (nonatomic, assign) CGFloat fc_bottom;
/**
* 左边
*/
@property (nonatomic, assign) CGFloat fc_left;
/**
* 右边
*/
@property (nonatomic, assign) CGFloat fc_right;
/**
* size
*/
@property (nonatomic, assign) CGSize fc_size;
/**
* 起点坐标
*/
@property (nonatomic, assign) CGPoint fc_origin;
@end
| //
// UIView+FCFrame.h
//
//
// Created by Charles on 16/9/1.
// Copyright © 2016年 Charles. All rights reserved.
//
#import <UIKit/UIKit.h>
@CLASS_0 FUNC_0 (VAR_1)
/**
* 快速根据xib创建View
*/
+ (ID_0)VAR_2;
/**
* 判断self和view是否重叠
*/
- (ID_1)VAR_3:(VAR_0 *)VAR_4;
/**
* 起点x坐标
*/
@FUNC_1 (nonatomic, VAR_5) VAR_6 VAR_7;
/**
* 起点y坐标
*/
@FUNC_1 (nonatomic, VAR_5) VAR_6 VAR_8;
/**
* 中心点x坐标
*/
@FUNC_1 (nonatomic, VAR_5) VAR_6 VAR_9;
/**
* 中心点y坐标
*/
@FUNC_1 (nonatomic, VAR_5) VAR_6 VAR_10;
/**
* 宽度
*/
@FUNC_1 (nonatomic, VAR_5) VAR_6 VAR_11;
/**
* 高度
*/
@FUNC_1 (nonatomic, VAR_5) VAR_6 VAR_12;
/**
* 顶部
*/
@FUNC_1 (nonatomic, VAR_5) VAR_6 VAR_13;
/**
* 底部
*/
@FUNC_1 (nonatomic, VAR_5) VAR_6 VAR_14;
/**
* 左边
*/
@FUNC_1 (nonatomic, VAR_5) VAR_6 VAR_15;
/**
* 右边
*/
@FUNC_1 (nonatomic, VAR_5) VAR_6 VAR_16;
/**
* size
*/
@FUNC_1 (nonatomic, VAR_5) VAR_17 VAR_18;
/**
* 起点坐标
*/
@FUNC_1 (nonatomic, VAR_5) VAR_19 VAR_20;
@CLASS_1
| 0.973283 | {'CLASS_0': 'interface', 'FUNC_0': 'UIView', 'VAR_0': 'UIView', 'VAR_1': 'FCFrame', 'ID_0': 'instancetype', 'VAR_2': 'fc_viewFromXib', 'ID_1': 'BOOL', 'VAR_3': 'fc_intersectsWithView', 'VAR_4': 'view', 'FUNC_1': 'property', 'VAR_5': 'assign', 'VAR_6': 'CGFloat', 'VAR_7': 'fc_x', 'VAR_8': 'fc_y', 'VAR_9': 'fc_centerX', 'VAR_10': 'fc_centerY', 'VAR_11': 'fc_width', 'VAR_12': 'fc_height', 'VAR_13': 'fc_top', 'VAR_14': 'fc_bottom', 'VAR_15': 'fc_left', 'VAR_16': 'fc_right', 'VAR_17': 'CGSize', 'VAR_18': 'fc_size', 'VAR_19': 'CGPoint', 'VAR_20': 'fc_origin', 'CLASS_1': 'end'} |
#include "fs.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "virtual_disk.h"
int fs_format(char *filename, uint16_t blocksize) {
vdisk_handle_t handle = vdisk_add(filename);
if (handle < 0) {
return -1;
}
int ret = myfs_format(handle, blocksize);
vdisk_remove(handle);
return ret;
}
char fs_mount(char *filename) {
vdisk_handle_t handle = vdisk_add(filename);
if (handle < 0) {
return -1;
}
for (uint8_t i = 0; i < MAX_FS_COUNT; i++) {
if (filesystems[i] == NULL) {
filesystems[i] = malloc(sizeof(myfs_t));
if (myfs_mount(handle, filesystems[i]) == 0) {
strcpy(filenames[i], filename);
if (strcmp(cur_dir, "") == 0) {
cur_dir[0] = 'A' + i;
strcpy(cur_dir + 1, ":/");
dir_entry_t *root = malloc(sizeof(dir_entry_t));
strcpy(root->name, "");
root->inode = 0;
root->file_type = FTYPE_DIR;
cur_dentry = root;
}
return 'A' + i;
}
}
}
return -1;
}
int fs_unmount(char c) {
if (c < 'A' || c > 'Z') {
return -1;
}
int i = c - 'A';
if (filesystems[i] != NULL && myfs_unmount(filesystems[i]) == 0) {
vdisk_remove(filesystems[i]->disk_handle);
filesystems[i] = NULL;
free(filesystems[i]);
if (cur_dir[0] == c) {
strcpy(cur_dir, "");
}
return 0;
}
return -1;
}
char *fs_pwd() { return cur_dir; }
void fs_df() {
printf("盘符\t磁盘文件名\t设备号\t块大小\t盘块数\t\t索引结点数\n");
for (uint8_t i = 0; i < MAX_FS_COUNT; i++) {
if (filesystems[i] != NULL) {
printf("%c\t%-10s\t%d\t%d\t%d/%d\t%d/%d\t\n", 'A' + i, filenames[i],
filesystems[i]->disk_handle, filesystems[i]->sb->block_size,
filesystems[i]->sb->free_blocks_count,
filesystems[i]->sb->blocks_count,
filesystems[i]->sb->free_inodes_count,
filesystems[i]->sb->inodes_count);
}
}
}
int fs_chdisk(char c) {
if (c < 'A' || c > 'Z') {
return -1;
}
int i = c - 'A';
if (filesystems[i] != NULL) {
cur_fs = i;
cur_dir[0] = 'A' + i;
strcpy(cur_dir + 1, ":/");
free(cur_dentry);
dir_entry_t *root = malloc(sizeof(dir_entry_t));
strcpy(root->name, "");
root->inode = 0;
root->file_type = FTYPE_DIR;
cur_dentry = root;
return 0;
}
return -1;
}
int fs_mkdir(char *path) {
// assert(0);
return myfs_mkdir(filesystems[cur_fs], cur_dentry, path);
}
int fs_touch(char *path) {
return myfs_touch(filesystems[cur_fs], cur_dentry, path);
}
int fs_ls() {
int ret = myfs_ls(filesystems[cur_fs], cur_dentry);
return ret;
}
int fs_rm(char *path) { return myfs_rm(filesystems[cur_fs], cur_dentry, path); }
int fs_cd(char *path) {
dir_entry_t *target =
myfs_search_dentry(filesystems[cur_fs], cur_dentry, path);
if (target != NULL && target->file_type == FTYPE_DIR) {
free(cur_dentry);
cur_dentry = target;
if (strcmp(path, "..") == 0) {
char *last_slash = strrchr(cur_dir, '/');
assert(last_slash != NULL);
*last_slash = '\0';
char *last_last_slash = strrchr(cur_dir, '/');
*(last_last_slash + 1) = '\0';
} else if (strcmp(path, ".") != 0) {
strcat(cur_dir, path);
strcat(cur_dir, "/");
}
return 0;
}
return -1;
}
int fs_stat(char *path) {
myfs_stat(filesystems[cur_fs], cur_dentry, path);
return 0;
}
int fs_link(char *link, char *target) {
return myfs_link(filesystems[cur_fs], link, cur_dentry, target);
}
int fs_chmod(char *path, uint16_t perm) {
return myfs_chmod(filesystems[cur_fs], cur_dentry, path, perm);
}
int fs_mv(char *from, char *to) {
if (fs_link(to, from) == 0 && fs_rm(from) == 0) {
return 0;
}
return -1;
}
| #include "fs.h"
#include <IMPORT_0>
#include <stdio.h>
#include <IMPORT_1>
#include <IMPORT_2>
#include "IMPORT_3"
int FUNC_0(char *filename, uint16_t VAR_0) {
CLASS_0 VAR_1 = FUNC_1(filename);
if (VAR_1 < 0) {
return -1;
}
int VAR_2 = FUNC_2(VAR_1, VAR_0);
FUNC_3(VAR_1);
return VAR_2;
}
char fs_mount(char *filename) {
CLASS_0 VAR_1 = FUNC_1(filename);
if (VAR_1 < 0) {
return -1;
}
for (uint8_t VAR_3 = 0; VAR_3 < MAX_FS_COUNT; VAR_3++) {
if (VAR_4[VAR_3] == NULL) {
VAR_4[VAR_3] = FUNC_4(sizeof(myfs_t));
if (FUNC_5(VAR_1, VAR_4[VAR_3]) == 0) {
strcpy(filenames[VAR_3], filename);
if (FUNC_6(VAR_5, "") == 0) {
VAR_5[0] = 'A' + VAR_3;
strcpy(VAR_5 + 1, ":/");
CLASS_1 *root = FUNC_4(sizeof(VAR_6));
strcpy(root->VAR_7, "");
root->VAR_8 = 0;
root->VAR_9 = FTYPE_DIR;
VAR_10 = root;
}
return 'A' + VAR_3;
}
}
}
return -1;
}
int FUNC_7(char VAR_11) {
if (VAR_11 < 'A' || VAR_11 > 'Z') {
return -1;
}
int VAR_3 = VAR_11 - 'A';
if (VAR_4[VAR_3] != NULL && FUNC_8(VAR_4[VAR_3]) == 0) {
FUNC_3(VAR_4[VAR_3]->VAR_12);
VAR_4[VAR_3] = NULL;
FUNC_9(VAR_4[VAR_3]);
if (VAR_5[0] == VAR_11) {
strcpy(VAR_5, "");
}
return 0;
}
return -1;
}
char *fs_pwd() { return VAR_5; }
void FUNC_10() {
FUNC_11("盘符\t磁盘文件名\t设备号\t块大小\t盘块数\t\t索引结点数\n");
for (uint8_t VAR_3 = 0; VAR_3 < MAX_FS_COUNT; VAR_3++) {
if (VAR_4[VAR_3] != NULL) {
FUNC_11("%c\t%-10s\t%d\t%d\t%d/%d\t%d/%d\t\n", 'A' + VAR_3, filenames[VAR_3],
VAR_4[VAR_3]->VAR_12, VAR_4[VAR_3]->VAR_13->VAR_14,
VAR_4[VAR_3]->VAR_13->VAR_15,
VAR_4[VAR_3]->VAR_13->VAR_16,
VAR_4[VAR_3]->VAR_13->VAR_17,
VAR_4[VAR_3]->VAR_13->inodes_count);
}
}
}
int FUNC_12(char VAR_11) {
if (VAR_11 < 'A' || VAR_11 > 'Z') {
return -1;
}
int VAR_3 = VAR_11 - 'A';
if (VAR_4[VAR_3] != NULL) {
VAR_18 = VAR_3;
VAR_5[0] = 'A' + VAR_3;
strcpy(VAR_5 + 1, ":/");
FUNC_9(VAR_10);
CLASS_1 *root = FUNC_4(sizeof(VAR_6));
strcpy(root->VAR_7, "");
root->VAR_8 = 0;
root->VAR_9 = FTYPE_DIR;
VAR_10 = root;
return 0;
}
return -1;
}
int FUNC_13(char *path) {
// assert(0);
return myfs_mkdir(VAR_4[VAR_18], VAR_10, path);
}
int FUNC_14(char *path) {
return myfs_touch(VAR_4[VAR_18], VAR_10, path);
}
int FUNC_15() {
int VAR_2 = myfs_ls(VAR_4[VAR_18], VAR_10);
return VAR_2;
}
int FUNC_16(char *path) { return myfs_rm(VAR_4[VAR_18], VAR_10, path); }
int fs_cd(char *path) {
CLASS_1 *VAR_19 =
FUNC_17(VAR_4[VAR_18], VAR_10, path);
if (VAR_19 != NULL && VAR_19->VAR_9 == FTYPE_DIR) {
FUNC_9(VAR_10);
VAR_10 = VAR_19;
if (FUNC_6(path, "..") == 0) {
char *VAR_20 = FUNC_18(VAR_5, '/');
FUNC_19(VAR_20 != NULL);
*VAR_20 = '\0';
char *VAR_21 = FUNC_18(VAR_5, '/');
*(VAR_21 + 1) = '\0';
} else if (FUNC_6(path, ".") != 0) {
FUNC_20(VAR_5, path);
FUNC_20(VAR_5, "/");
}
return 0;
}
return -1;
}
int FUNC_21(char *path) {
myfs_stat(VAR_4[VAR_18], VAR_10, path);
return 0;
}
int FUNC_22(char *link, char *VAR_19) {
return myfs_link(VAR_4[VAR_18], link, VAR_10, VAR_19);
}
int FUNC_23(char *path, uint16_t VAR_22) {
return myfs_chmod(VAR_4[VAR_18], VAR_10, path, VAR_22);
}
int FUNC_24(char *VAR_23, char *VAR_24) {
if (FUNC_22(VAR_24, VAR_23) == 0 && FUNC_16(VAR_23) == 0) {
return 0;
}
return -1;
}
| 0.776739 | {'IMPORT_0': 'assert.h', 'IMPORT_1': 'stdlib.h', 'IMPORT_2': 'string.h', 'IMPORT_3': 'virtual_disk.h', 'FUNC_0': 'fs_format', 'VAR_0': 'blocksize', 'CLASS_0': 'vdisk_handle_t', 'VAR_1': 'handle', 'FUNC_1': 'vdisk_add', 'VAR_2': 'ret', 'FUNC_2': 'myfs_format', 'FUNC_3': 'vdisk_remove', 'VAR_3': 'i', 'VAR_4': 'filesystems', 'FUNC_4': 'malloc', 'FUNC_5': 'myfs_mount', 'FUNC_6': 'strcmp', 'VAR_5': 'cur_dir', 'CLASS_1': 'dir_entry_t', 'VAR_6': 'dir_entry_t', 'VAR_7': 'name', 'VAR_8': 'inode', 'VAR_9': 'file_type', 'VAR_10': 'cur_dentry', 'FUNC_7': 'fs_unmount', 'VAR_11': 'c', 'FUNC_8': 'myfs_unmount', 'VAR_12': 'disk_handle', 'FUNC_9': 'free', 'FUNC_10': 'fs_df', 'FUNC_11': 'printf', 'VAR_13': 'sb', 'VAR_14': 'block_size', 'VAR_15': 'free_blocks_count', 'VAR_16': 'blocks_count', 'VAR_17': 'free_inodes_count', 'FUNC_12': 'fs_chdisk', 'VAR_18': 'cur_fs', 'FUNC_13': 'fs_mkdir', 'FUNC_14': 'fs_touch', 'FUNC_15': 'fs_ls', 'FUNC_16': 'fs_rm', 'VAR_19': 'target', 'FUNC_17': 'myfs_search_dentry', 'VAR_20': 'last_slash', 'FUNC_18': 'strrchr', 'FUNC_19': 'assert', 'VAR_21': 'last_last_slash', 'FUNC_20': 'strcat', 'FUNC_21': 'fs_stat', 'FUNC_22': 'fs_link', 'FUNC_23': 'fs_chmod', 'VAR_22': 'perm', 'FUNC_24': 'fs_mv', 'VAR_23': 'from', 'VAR_24': 'to'} |
/*******************************************************************************
*
* FUNCTION: FlOpenInputFile
*
* PARAMETERS: InputFilename - The user-specified ASL source file to be
* compiled
*
* RETURN: Status
*
* DESCRIPTION: Open the specified input file, and save the directory path to
* the file so that include files can be opened in
* the same directory.
*
******************************************************************************/
ACPI_STATUS
FlOpenInputFile (
char *InputFilename)
{
FlOpenFile (ASL_FILE_INPUT, InputFilename, "r");
AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle;
return (AE_OK);
} | /*******************************************************************************
*
* FUNCTION: FlOpenInputFile
*
* PARAMETERS: InputFilename - The user-specified ASL source file to be
* compiled
*
* RETURN: Status
*
* DESCRIPTION: Open the specified input file, and save the directory path to
* the file so that include files can be opened in
* the same directory.
*
******************************************************************************/
ACPI_STATUS
FUNC_0 (
char *VAR_0)
{
FUNC_1 (VAR_1, VAR_0, "r");
VAR_2 = VAR_3[VAR_1].VAR_4;
return (VAR_5);
} | 0.930621 | {'FUNC_0': 'FlOpenInputFile', 'VAR_0': 'InputFilename', 'FUNC_1': 'FlOpenFile', 'VAR_1': 'ASL_FILE_INPUT', 'VAR_2': 'AslCompilerin', 'VAR_3': 'Gbl_Files', 'VAR_4': 'Handle', 'VAR_5': 'AE_OK'} |
//
// Created by Mookel on 16/10/1.
// Email : <EMAIL>
// Copyright (c) 2016 jlu.edu. All rights reserved.
// llcode.c : Print various tables needed for a llama-generated
// LL(1) parser.
//
/* A llama-generated LL(1) parser including following tables:
*
* Yyd[][] : The parser state machine's DFA transition table.
* The horizontal axis is input symbol and the vertical axis is
* top-of-stack symbol. Only nonterminal TOS symbols are in the
* table.The table contains the production number of a production
* to apply or -1 if this is an error transition.
*
* YydN[] : (N is 1-3 decimal digits).It is used for compressed tables only.
* Holds the compressed rows.
*
* Yy_pushtab[] : Indexed by production number, evaluates to a list of objects to
* YypDD[] push on the stack when that production is replaced.The YypDD array
* are lists of objects and Yy_pushtab is an array of pointers to
* those lists.
*
* Yy_snonterm[] : For debugging, indexed by nonterminal, evaluates to the name of the
* nonterminal.
*
* Yy_sact[] : Same as above but for actions.
* Yy_synch[] : Array of synchronization tokens for error recovery.
* yy_act() : Subroutine containing the actions.
* Yy_stok[] : Made in stok.c. For the most part, the numbers in these tables are
* the same as those in the symbol table. The exceptions are the token
* values, which are shifted down so that the smallest token has the
* value of 1(0 is used for EOI).
*/
#include <stdlib.h>
#include <ctype.h>
#include "parser.h"
#define DTRAN "Yyd" /*Name of DFA transition table*/
/*local static variables*/
PRIVATE int *_dtran;
/*local static functions declarations*/
PRIVATE void fill_row(SYMBOL_S *lhs);
PRIVATE void make_pushtab(SYMBOL_S *lhs);
PRIVATE void make_yy_pushtab(void);
PRIVATE void make_yy_dtran(void);
PRIVATE void make_yy_synch(void);
PRIVATE void make_yy_snonterm(void);
PRIVATE void make_yy_sact(void);
PRIVATE void make_acts(SYMBOL_S *lhs);
PRIVATE void make_yy_act(void);
PUBLIC void tables()
{
make_yy_pushtab();
make_yy_dtran();
make_yy_act();
make_yy_synch();
make_yy_stok();
make_token_file();
output("\n #ifdef YYDEBUG\n");
make_yy_snonterm();
make_yy_sact();
output("\n #endif\n");
}
/* Make one row of the parser's DFA transition table. Column 0 is used
* for the EOI condition;other columns are indexed by nonterminal(with
* the number normalized for the smallest nonterminal).That is, the
* terminal values in the symbol table are shifted downwards so that
* the smallest terminal value is 1 rather than MINTERM.The row indexes
* are adjusted in the same way(so that row 0 is used for MINNONTERM).
*
*/
PRIVATE void fill_row(SYMBOL_S *lhs)
{
PRODUCTION_S *prod;
int *row;
int i ;
int rowsize;
if(!ISNONTERM(lhs)) return;
rowsize = USED_TERMS + 1;
row = _dtran + ((i = ADJ_VAL(lhs->val)) * rowsize);
for(prod = lhs->productions; prod; prod = prod->next) {
set_next_member(NULL);
while((i = set_next_member(prod->select)) >= 0) {
if(row[i] == -1) {
row[i] = prod->num;
} else {
error(NONFATAL, "Grammar not LL(1), select-set conflict in ");
error(NOHDR, "<%s>, line %d\n", lhs->name, lhs->lineno);
}
}
}
}
/*
* Make the pushtab.The right-hand sides are output in reverse order
* (to make the pushing easier) by stacking them and then printing
* items off the stack.
*/
PRIVATE void make_pushtab(SYMBOL_S *lhs)
{
register int i;
PRODUCTION_S *prod;
SYMBOL_S **sym;
SYMBOL_S *stack[MAXRHS], **sp;
sp = &stack[-1];
for(prod = lhs->productions; prod; prod = prod->next) {
output("YYPRIVATE int Yyp%-2d[ ] = { ", prod->num);
for(sym = prod->rhs, i = prod->rhs_len; --i >= 0;)
*++sp = *sym++;
for(; INBOUNDS(stack, sp); output("%d, ", (*sp--)->val))
;
output("0 };\n", prod->rhs[0]);
}
}
PRIVATE void make_yy_pushtab()
{
register int i;
register int maxprod = g_num_productons - 1;
static char *text[] = {
"The YypNN arrays hold the right-hand sides of productions, listed back",
"to front (so that they are pushed in reverse order), NN is the production",
"number (to be found in the symbol-table listing output with a -s switch).",
"",
"Yy_pushtab[] is indexed by production number and points to the appropriate",
"right-hand side (YypNN) array.",
NULL
};
sys_comment(g_output, text);
hash_print_tab(g_symtab, (fp_tab_print_t)make_pushtab, NULL, 0);
output("\YYPRIVATE int *Yy_pushtab[ ] = \n{\n");
for(i = 0;i < maxprod; ++i)
output("\tYyp%-2d,\n", i);
output("\tYyp%-2d\n};\n", maxprod);
}
/*print the DFA transition table.*/
PRIVATE void make_yy_dtran()
{
int i;
int nterms, nnonterms;
static char *text[] = {
"Yyd[][] is the DFA transition table for the parser. It is indexed as follows:",
"",
" Input symbol",
" +---------------------+",
" L | production number |",
" H | or YYF |",
" S | |",
" +---------------------+",
"",
"The production number is used as an index into Yy_pushtab, which looks like: ",
"",
" Yy_pushtab YypDD:",
" +--------+ +----------------+",
" | *----|----->| |",
" +--------+ +----------------+",
" | *----|----->",
" +--------+",
" | *----|----->",
" +--------+",
"",
"YypDD is the tokenized right-hand side of the production.Generate a symbol",
"table listing with llama's -l command-line switch to get both production",
"numbers and the meanings of the YypDD string contents.",
NULL
};
nterms = USED_TERMS + 1; /*+1 for EOI*/
nnonterms = USED_NONTERMS;
i = nterms * nnonterms;
if(!(_dtran = (int *)GC_MALLOC(i * sizeof(*_dtran))))
com_ferr("Out of memory.\n");
sys_memiset(_dtran, -1, i);
hash_print_tab(g_symtab, (fp_tab_print_t)fill_row, NULL, 0);
sys_comment(g_output, text);
if(g_cmdopt.uncompressed) {
fprintf(g_output, "YYPRIVATE YY_TTYPE %s[ %d ][ %d ] = \n", DTRAN, nnonterms, nterms);
sys_print_array(g_output, _dtran, nnonterms, nterms);
sys_print_defnext(g_output, DTRAN);
if(g_cmdopt.verbose) printf("%d bytes required for tables.\n", i * sizeof(YY_TTYPE));
} else {
i = sys_pairs(g_output, _dtran, nnonterms, nterms, DTRAN, g_cmdopt.threshold, 1);
sys_pnext(g_output, DTRAN);
if(g_cmdopt.verbose)
printf("%d bytes required for compressed tables.\n", (i*sizeof(YY_TTYPE)) +
(nnonterms * sizeof(YY_TTYPE *)));
}
output("\n\n");
}
PRIVATE void make_yy_synch()
{
int mem;
int i;
static char *text[] = {
"Yy_synch[] is an array of synchronization tokens. When an error is detected, ",
"stack items are popped until one of the tokens in this array is encountered.",
"The input is then read until the same item is found. Then parsing continues.",
NULL,
};
sys_comment(g_output, text);
output("YYPRIVATE int Yy_synch[] = \n{\n");
i = 0;
for(set_next_member(NULL); (mem = set_next_member(g_synch)) >= 0;){
output("\t%s,\n", g_terms[mem]->name); /*Note: name will be macro after output.*/
++i;
}
/*No members in synch set.*/
if(i == 0) output("\t_EOI_,\n"); /*',' is added by mookel.*/
output("\t-1\n};\n");
set_next_member(NULL);
}
PRIVATE void make_yy_snonterm()
{
register int i;
static char *text[] = {
"Yy_snonterm[] is used only for debugging.It is indexed by the tokenized left-hand",
"side(as used for a row index in Yyd[]) and evaluates to a string naming that lhs.",
NULL
};
sys_comment(g_output, text);
output("char *Yy_snonterm[] = \n{\n");
for(i = MINNONTERM; i <= g_currnonterm; ++i){
if(g_terms[i]) output("\t/* %3d */ \"%s\"", i, g_terms[i]->name);
if(i != g_currnonterm) outc(',');
outc('\n');
}
output("};\n\n");
}
PRIVATE void make_yy_sact()
{
register int i;
static char* text[] = {
"Yy_sact[] is alse used only for debugging. It is indexed by the internal value",
"used for an action symbol and evaluates to a string naming that token symbol.",
NULL
};
sys_comment(g_output, text);
output("char *Yy_sact[] = \n{\n\t");
if(g_curract < MINACT) {
output("NULL /* There are no actions */");
} else {
for(i = MINACT; i <= g_curract; ++i) {
output("\"{%d}\"%c", i - MINACT, i < g_curract ? ',' : ' ');
if(i == g_curract) {
output("\n");
} else {
output("\n\t");
}
}
}
output("};\n");
}
/*
* This rubroutine is called indirectly from yy_act, through the subroutine
* hash_print_tab(). It prints the text associated with one of the acts.
*/
PRIVATE void make_acts(SYMBOL_S *lhs)
{
char *p;
int num;
char fname[80], *fp;
int i;
if(!lhs->string) return;
output(" case %d:\n", lhs->val);
if(g_cmdopt.no_lines){
output("\t\t");
} else {
output("#line %d\"%s\"\n\t\t", lhs->lineno, g_input_file_name);
}
output(" ");
for(p = lhs->string; *p;) {
if(*p == '\r') continue;
if(*p != '$'){
output("%c", *p++);
} else {
/*skip the attribute reference. The if statement handles $$, the else
*clause handles the two forms: $N and $-N, where N is a decimal number.
* When you hit the do_dollar call, "num" holds the number assocaiated
* with N, or DOLLAR_DOLLAR in the case of $$.
*/
if(*++p != '<') {
*fname = '\0';
} else { /*TODO: deal with <field>*/
}
if(*p == '$') { /* case of "$$" */
num = DOLLAR_DOLLAR;
++p;
} else {
num = atoi(p);
if(*p == '-') ++p;
while(isdigit(*p)) ++p;
}
output("%s", do_dollar(num, 0, 0, NULL, fname));
}
}
output("\n break;\n");
}
PRIVATE void make_yy_act()
{
static char *text[] ={
"Yy_act() is the action subroutine. It is passed the tokenized value of",
"an action and executes the corresponding code.",
NULL
};
static char *top[] = {
"YYPRIVATE int yy_act(int actnum)",
"{",
" /*The actions. Returns 0 normally but a nonzero error code can be ret-",
" *-urned,if one of the acts causes the parser to terminate abnormally.",
" */",
"",
" switch(actnum) {",
NULL
};
static char *bottom[] = {
" default: printf(\"INTERNAL ERROR: Illegal action number (%d)\\n\", actnum);",
" break;",
" }",
" return 0;",
"}",
NULL
};
sys_comment(g_output, text);
sys_printv(g_output, top);
hash_print_tab(g_symtab, (fp_tab_print_t)make_acts, NULL, 0);
sys_printv(g_output, bottom);
}
| //
// Created by Mookel on 16/10/1.
// Email : <EMAIL>
// Copyright (c) 2016 jlu.edu. All rights reserved.
// llcode.c : Print various tables needed for a llama-generated
// LL(1) parser.
//
/* A llama-generated LL(1) parser including following tables:
*
* Yyd[][] : The parser state machine's DFA transition table.
* The horizontal axis is input symbol and the vertical axis is
* top-of-stack symbol. Only nonterminal TOS symbols are in the
* table.The table contains the production number of a production
* to apply or -1 if this is an error transition.
*
* YydN[] : (N is 1-3 decimal digits).It is used for compressed tables only.
* Holds the compressed rows.
*
* Yy_pushtab[] : Indexed by production number, evaluates to a list of objects to
* YypDD[] push on the stack when that production is replaced.The YypDD array
* are lists of objects and Yy_pushtab is an array of pointers to
* those lists.
*
* Yy_snonterm[] : For debugging, indexed by nonterminal, evaluates to the name of the
* nonterminal.
*
* Yy_sact[] : Same as above but for actions.
* Yy_synch[] : Array of synchronization tokens for error recovery.
* yy_act() : Subroutine containing the actions.
* Yy_stok[] : Made in stok.c. For the most part, the numbers in these tables are
* the same as those in the symbol table. The exceptions are the token
* values, which are shifted down so that the smallest token has the
* value of 1(0 is used for EOI).
*/
#include <IMPORT_0>
#include <ctype.h>
#include "IMPORT_1"
#define VAR_0 "Yyd" /*Name of DFA transition table*/
/*local static variables*/
CLASS_0 VAR_1 *VAR_2;
/*local static functions declarations*/
CLASS_0 VAR_3 FUNC_0(CLASS_1 *VAR_5);
CLASS_0 VAR_3 FUNC_1(CLASS_1 *VAR_5);
CLASS_0 VAR_3 FUNC_2(void);
CLASS_0 VAR_3 FUNC_3(void);
CLASS_0 VAR_3 FUNC_4(void);
CLASS_0 VAR_3 FUNC_5(void);
CLASS_0 VAR_3 FUNC_6(void);
CLASS_0 VAR_3 FUNC_7(CLASS_1 *VAR_5);
CLASS_0 VAR_3 FUNC_8(void);
CLASS_2 VAR_3 FUNC_9()
{
FUNC_2();
FUNC_3();
FUNC_8();
FUNC_4();
FUNC_10();
FUNC_11();
FUNC_12("\n #ifdef YYDEBUG\n");
FUNC_5();
FUNC_6();
FUNC_12("\n #endif\n");
}
/* Make one row of the parser's DFA transition table. Column 0 is used
* for the EOI condition;other columns are indexed by nonterminal(with
* the number normalized for the smallest nonterminal).That is, the
* terminal values in the symbol table are shifted downwards so that
* the smallest terminal value is 1 rather than MINTERM.The row indexes
* are adjusted in the same way(so that row 0 is used for MINNONTERM).
*
*/
CLASS_0 VAR_3 FUNC_0(CLASS_1 *VAR_5)
{
CLASS_3 *VAR_8;
int *VAR_9;
int VAR_10 ;
int VAR_11;
if(!FUNC_13(VAR_5)) return;
VAR_11 = VAR_12 + 1;
VAR_9 = VAR_2 + ((VAR_10 = FUNC_14(VAR_5->VAR_13)) * VAR_11);
for(VAR_8 = VAR_5->VAR_14; VAR_8; VAR_8 = VAR_8->VAR_15) {
FUNC_15(NULL);
while((VAR_10 = FUNC_15(VAR_8->VAR_16)) >= 0) {
if(VAR_9[VAR_10] == -1) {
VAR_9[VAR_10] = VAR_8->VAR_17;
} else {
error(VAR_18, "Grammar not LL(1), select-set conflict in ");
error(VAR_19, "<%s>, line %d\n", VAR_5->VAR_20, VAR_5->VAR_21);
}
}
}
}
/*
* Make the pushtab.The right-hand sides are output in reverse order
* (to make the pushing easier) by stacking them and then printing
* items off the stack.
*/
CLASS_0 VAR_3 FUNC_1(CLASS_1 *VAR_5)
{
register int VAR_10;
CLASS_3 *VAR_8;
CLASS_1 **VAR_22;
CLASS_1 *VAR_23[VAR_24], **VAR_25;
VAR_25 = &VAR_23[-1];
for(VAR_8 = VAR_5->VAR_14; VAR_8; VAR_8 = VAR_8->VAR_15) {
FUNC_12("YYPRIVATE int Yyp%-2d[ ] = { ", VAR_8->VAR_17);
for(VAR_22 = VAR_8->VAR_26, VAR_10 = VAR_8->VAR_27; --VAR_10 >= 0;)
*++VAR_25 = *VAR_22++;
for(; FUNC_16(VAR_23, VAR_25); FUNC_12("%d, ", (*VAR_25--)->VAR_13))
;
FUNC_12("0 };\n", VAR_8->VAR_26[0]);
}
}
CLASS_0 VAR_3 FUNC_2()
{
register int VAR_10;
register int VAR_28 = VAR_29 - 1;
static char *VAR_30[] = {
"The YypNN arrays hold the right-hand sides of productions, listed back",
"to front (so that they are pushed in reverse order), NN is the production",
"number (to be found in the symbol-table listing output with a -s switch).",
"",
"Yy_pushtab[] is indexed by production number and points to the appropriate",
"right-hand side (YypNN) array.",
NULL
};
FUNC_17(VAR_31, VAR_30);
FUNC_18(VAR_32, (ID_0)VAR_6, NULL, 0);
FUNC_12("\YYPRIVATE int *Yy_pushtab[ ] = \n{\n");
for(VAR_10 = 0;VAR_10 < VAR_28; ++VAR_10)
FUNC_12("\tYyp%-2d,\n", VAR_10);
FUNC_12("\tYyp%-2d\n};\n", VAR_28);
}
/*print the DFA transition table.*/
CLASS_0 VAR_3 FUNC_3()
{
int VAR_10;
int VAR_33, VAR_34;
static char *VAR_30[] = {
"Yyd[][] is the DFA transition table for the parser. It is indexed as follows:",
"",
" Input symbol",
" +---------------------+",
" L | production number |",
" H | or YYF |",
" S | |",
" +---------------------+",
"",
"The production number is used as an index into Yy_pushtab, which looks like: ",
"",
" Yy_pushtab YypDD:",
" +--------+ +----------------+",
" | *----|----->| |",
" +--------+ +----------------+",
" | *----|----->",
" +--------+",
" | *----|----->",
" +--------+",
"",
"YypDD is the tokenized right-hand side of the production.Generate a symbol",
"table listing with llama's -l command-line switch to get both production",
"numbers and the meanings of the YypDD string contents.",
NULL
};
VAR_33 = VAR_12 + 1; /*+1 for EOI*/
VAR_34 = VAR_35;
VAR_10 = VAR_33 * VAR_34;
if(!(VAR_2 = (int *)FUNC_19(VAR_10 * sizeof(*VAR_2))))
FUNC_20("Out of memory.\n");
FUNC_21(VAR_2, -1, VAR_10);
FUNC_18(VAR_32, (ID_0)VAR_4, NULL, 0);
FUNC_17(VAR_31, VAR_30);
if(VAR_36.VAR_37) {
FUNC_22(VAR_31, "YYPRIVATE YY_TTYPE %s[ %d ][ %d ] = \n", VAR_0, VAR_34, VAR_33);
FUNC_23(VAR_31, VAR_2, VAR_34, VAR_33);
FUNC_24(VAR_31, VAR_0);
if(VAR_36.VAR_38) FUNC_25("%d bytes required for tables.\n", VAR_10 * sizeof(VAR_39));
} else {
VAR_10 = FUNC_26(VAR_31, VAR_2, VAR_34, VAR_33, VAR_0, VAR_36.VAR_40, 1);
FUNC_27(VAR_31, VAR_0);
if(VAR_36.VAR_38)
FUNC_25("%d bytes required for compressed tables.\n", (VAR_10*sizeof(VAR_39)) +
(VAR_34 * sizeof(CLASS_4 *)));
}
FUNC_12("\n\n");
}
CLASS_0 VAR_3 FUNC_4()
{
int VAR_41;
int VAR_10;
static char *VAR_30[] = {
"Yy_synch[] is an array of synchronization tokens. When an error is detected, ",
"stack items are popped until one of the tokens in this array is encountered.",
"The input is then read until the same item is found. Then parsing continues.",
NULL,
};
FUNC_17(VAR_31, VAR_30);
FUNC_12("YYPRIVATE int Yy_synch[] = \n{\n");
VAR_10 = 0;
for(FUNC_15(NULL); (VAR_41 = FUNC_15(g_synch)) >= 0;){
FUNC_12("\t%s,\n", VAR_42[VAR_41]->VAR_20); /*Note: name will be macro after output.*/
++VAR_10;
}
/*No members in synch set.*/
if(VAR_10 == 0) FUNC_12("\t_EOI_,\n"); /*',' is added by mookel.*/
FUNC_12("\t-1\n};\n");
FUNC_15(NULL);
}
CLASS_0 VAR_3 FUNC_5()
{
register int VAR_10;
static char *VAR_30[] = {
"Yy_snonterm[] is used only for debugging.It is indexed by the tokenized left-hand",
"side(as used for a row index in Yyd[]) and evaluates to a string naming that lhs.",
NULL
};
FUNC_17(VAR_31, VAR_30);
FUNC_12("char *Yy_snonterm[] = \n{\n");
for(VAR_10 = VAR_43; VAR_10 <= VAR_44; ++VAR_10){
if(VAR_42[VAR_10]) FUNC_12("\t/* %3d */ \"%s\"", VAR_10, VAR_42[VAR_10]->VAR_20);
if(VAR_10 != VAR_44) FUNC_28(',');
FUNC_28('\n');
}
FUNC_12("};\n\n");
}
CLASS_0 VAR_3 FUNC_6()
{
register int VAR_10;
static char* VAR_30[] = {
"Yy_sact[] is alse used only for debugging. It is indexed by the internal value",
"used for an action symbol and evaluates to a string naming that token symbol.",
NULL
};
FUNC_17(VAR_31, VAR_30);
FUNC_12("char *Yy_sact[] = \n{\n\t");
if(VAR_45 < VAR_46) {
FUNC_12("NULL /* There are no actions */");
} else {
for(VAR_10 = VAR_46; VAR_10 <= VAR_45; ++VAR_10) {
FUNC_12("\"{%d}\"%c", VAR_10 - VAR_46, VAR_10 < VAR_45 ? ',' : ' ');
if(VAR_10 == VAR_45) {
FUNC_12("\n");
} else {
FUNC_12("\n\t");
}
}
}
FUNC_12("};\n");
}
/*
* This rubroutine is called indirectly from yy_act, through the subroutine
* hash_print_tab(). It prints the text associated with one of the acts.
*/
CLASS_0 VAR_3 FUNC_7(CLASS_1 *VAR_5)
{
char *VAR_47;
int VAR_17;
char VAR_48[80], *VAR_49;
int VAR_10;
if(!VAR_5->VAR_50) return;
FUNC_12(" case %d:\n", VAR_5->VAR_13);
if(VAR_36.VAR_51){
FUNC_12("\t\t");
} else {
FUNC_12("#line %d\"%s\"\n\t\t", VAR_5->VAR_21, VAR_52);
}
FUNC_12(" ");
for(VAR_47 = VAR_5->VAR_50; *VAR_47;) {
if(*VAR_47 == '\r') continue;
if(*VAR_47 != '$'){
FUNC_12("%c", *VAR_47++);
} else {
/*skip the attribute reference. The if statement handles $$, the else
*clause handles the two forms: $N and $-N, where N is a decimal number.
* When you hit the do_dollar call, "num" holds the number assocaiated
* with N, or DOLLAR_DOLLAR in the case of $$.
*/
if(*++VAR_47 != '<') {
*VAR_48 = '\0';
} else { /*TODO: deal with <field>*/
}
if(*VAR_47 == '$') { /* case of "$$" */
VAR_17 = VAR_53;
++VAR_47;
} else {
VAR_17 = FUNC_29(VAR_47);
if(*VAR_47 == '-') ++VAR_47;
while(FUNC_30(*VAR_47)) ++VAR_47;
}
FUNC_12("%s", FUNC_31(VAR_17, 0, 0, NULL, VAR_48));
}
}
FUNC_12("\n break;\n");
}
CLASS_0 VAR_3 FUNC_8()
{
static char *VAR_30[] ={
"Yy_act() is the action subroutine. It is passed the tokenized value of",
"an action and executes the corresponding code.",
NULL
};
static char *VAR_54[] = {
"YYPRIVATE int yy_act(int actnum)",
"{",
" /*The actions. Returns 0 normally but a nonzero error code can be ret-",
" *-urned,if one of the acts causes the parser to terminate abnormally.",
" */",
"",
" switch(actnum) {",
NULL
};
static char *VAR_55[] = {
" default: printf(\"INTERNAL ERROR: Illegal action number (%d)\\n\", actnum);",
" break;",
" }",
" return 0;",
"}",
NULL
};
FUNC_17(VAR_31, VAR_30);
FUNC_32(VAR_31, VAR_54);
FUNC_18(VAR_32, (ID_0)VAR_7, NULL, 0);
FUNC_32(VAR_31, VAR_55);
}
| 0.962004 | {'IMPORT_0': 'stdlib.h', 'IMPORT_1': 'parser.h', 'VAR_0': 'DTRAN', 'CLASS_0': 'PRIVATE', 'VAR_1': 'int', 'VAR_2': '_dtran', 'VAR_3': 'void', 'FUNC_0': 'fill_row', 'VAR_4': 'fill_row', 'CLASS_1': 'SYMBOL_S', 'VAR_5': 'lhs', 'FUNC_1': 'make_pushtab', 'VAR_6': 'make_pushtab', 'FUNC_2': 'make_yy_pushtab', 'FUNC_3': 'make_yy_dtran', 'FUNC_4': 'make_yy_synch', 'FUNC_5': 'make_yy_snonterm', 'FUNC_6': 'make_yy_sact', 'FUNC_7': 'make_acts', 'VAR_7': 'make_acts', 'FUNC_8': 'make_yy_act', 'CLASS_2': 'PUBLIC', 'FUNC_9': 'tables', 'FUNC_10': 'make_yy_stok', 'FUNC_11': 'make_token_file', 'FUNC_12': 'output', 'CLASS_3': 'PRODUCTION_S', 'VAR_8': 'prod', 'VAR_9': 'row', 'VAR_10': 'i', 'VAR_11': 'rowsize', 'FUNC_13': 'ISNONTERM', 'VAR_12': 'USED_TERMS', 'FUNC_14': 'ADJ_VAL', 'VAR_13': 'val', 'VAR_14': 'productions', 'VAR_15': 'next', 'FUNC_15': 'set_next_member', 'VAR_16': 'select', 'VAR_17': 'num', 'VAR_18': 'NONFATAL', 'VAR_19': 'NOHDR', 'VAR_20': 'name', 'VAR_21': 'lineno', 'VAR_22': 'sym', 'VAR_23': 'stack', 'VAR_24': 'MAXRHS', 'VAR_25': 'sp', 'VAR_26': 'rhs', 'VAR_27': 'rhs_len', 'FUNC_16': 'INBOUNDS', 'VAR_28': 'maxprod', 'VAR_29': 'g_num_productons', 'VAR_30': 'text', 'FUNC_17': 'sys_comment', 'VAR_31': 'g_output', 'FUNC_18': 'hash_print_tab', 'VAR_32': 'g_symtab', 'ID_0': 'fp_tab_print_t', 'VAR_33': 'nterms', 'VAR_34': 'nnonterms', 'VAR_35': 'USED_NONTERMS', 'FUNC_19': 'GC_MALLOC', 'FUNC_20': 'com_ferr', 'FUNC_21': 'sys_memiset', 'VAR_36': 'g_cmdopt', 'VAR_37': 'uncompressed', 'FUNC_22': 'fprintf', 'FUNC_23': 'sys_print_array', 'FUNC_24': 'sys_print_defnext', 'VAR_38': 'verbose', 'FUNC_25': 'printf', 'VAR_39': 'YY_TTYPE', 'CLASS_4': 'YY_TTYPE', 'FUNC_26': 'sys_pairs', 'VAR_40': 'threshold', 'FUNC_27': 'sys_pnext', 'VAR_41': 'mem', 'VAR_42': 'g_terms', 'VAR_43': 'MINNONTERM', 'VAR_44': 'g_currnonterm', 'FUNC_28': 'outc', 'VAR_45': 'g_curract', 'VAR_46': 'MINACT', 'VAR_47': 'p', 'VAR_48': 'fname', 'VAR_49': 'fp', 'VAR_50': 'string', 'VAR_51': 'no_lines', 'VAR_52': 'g_input_file_name', 'VAR_53': 'DOLLAR_DOLLAR', 'FUNC_29': 'atoi', 'FUNC_30': 'isdigit', 'FUNC_31': 'do_dollar', 'VAR_54': 'top', 'VAR_55': 'bottom', 'FUNC_32': 'sys_printv'} |
/**
* perfstats_done(P):
* Log final statistics and free the performance statistics cookie ${P}. On
* error, the statistics may have not been written but the cookie will still
* have been freed.
*/
int
perfstats_done(struct perfstats * P)
{
int rc;
rc = flush(P);
if (P->timer_cookie) {
events_timer_cancel(P->timer_cookie);
P->timer_cookie = NULL;
}
reqstatslist_free(P->stats);
free(P);
return (rc);
} | /**
* perfstats_done(P):
* Log final statistics and free the performance statistics cookie ${P}. On
* error, the statistics may have not been written but the cookie will still
* have been freed.
*/
int
perfstats_done(struct perfstats * P)
{
int rc;
rc = FUNC_0(P);
if (P->VAR_0) {
events_timer_cancel(P->VAR_0);
P->VAR_0 = NULL;
}
reqstatslist_free(P->stats);
FUNC_1(P);
return (rc);
} | 0.355521 | {'FUNC_0': 'flush', 'VAR_0': 'timer_cookie', 'FUNC_1': 'free'} |
#pragma once
#include "iparamlist.h"
#include "optioninfo.h"
#include "string_utils.h"
#include <cmdlime/errors.h>
#include <cmdlime/customnames.h>
#include <cmdlime/stringconverter.h>
#include <vector>
#include <sstream>
#include <functional>
#include <memory>
namespace cmdlime::detail{
namespace str = string_utils;
template <typename T>
class ParamList : public IParamList{
public:
ParamList(std::string name,
std::string shortName,
std::string type,
std::vector<T>& paramListValue)
: info_(std::move(name), std::move(shortName), std::move(type))
, paramListValue_(paramListValue)
{
}
void setDefaultValue(const std::vector<T>& value)
{
hasValue_ = true;
defaultValue_ = value;
}
OptionInfo& info() override
{
return info_;
}
const OptionInfo& info() const override
{
return info_;
}
OptionType type() const override
{
return OptionType::ParamList;
}
private:
bool read(const std::string& data) override
{
if (!isDefaultValueOverwritten_){
paramListValue_.clear();
isDefaultValueOverwritten_ = true;
}
const auto dataParts = str::split(data, ",");
for (const auto& part : dataParts){
auto paramVal = convertFromString<T>(part);
if (!paramVal)
return false;
paramListValue_.emplace_back(*paramVal);
}
hasValue_ = true;
return true;
}
bool hasValue() const override
{
return hasValue_;
}
bool isOptional() const override
{
return defaultValue_.has_value();
}
std::string defaultValue() const override
{
if (!defaultValue_)
return {};
auto stream = std::stringstream{};
stream << "{";
auto firstVal = true;
for (auto& val : *defaultValue_){
auto valStr = convertToString(val);
if (!valStr)
return {};
if (!firstVal)
stream << ", ";
firstVal = false;
if (valStr->empty())
stream << "\"\"";
else
stream << *valStr;
}
stream << "}";
return stream.str();
}
private:
OptionInfo info_;
std::vector<T>& paramListValue_;
bool hasValue_ = false;
std::optional<std::vector<T>> defaultValue_;
bool isDefaultValueOverwritten_ = false;
};
}
| #pragma once
#include "IMPORT_0"
#include "IMPORT_1"
#include "string_utils.h"
#include <IMPORT_2>
#include <IMPORT_3>
#include <IMPORT_4>
#include <IMPORT_5>
#include <IMPORT_6>
#include <IMPORT_7>
#include <memory>
namespace cmdlime::VAR_0{
namespace VAR_1 = VAR_2;
template <VAR_3 VAR_4>
VAR_5 ParamList : VAR_6 VAR_7{
public:
ParamList(std::VAR_8 VAR_9,
std::VAR_8 shortName,
std::VAR_8 type,
std::IMPORT_5<VAR_4>& VAR_10)
: info_(std::FUNC_1(VAR_9), std::FUNC_1(shortName), std::FUNC_1(type))
, FUNC_2(VAR_10)
{
}
void setDefaultValue(const std::IMPORT_5<VAR_4>& value)
{
hasValue_ = true;
VAR_12 = value;
}
VAR_13& FUNC_3() VAR_14
{
return info_;
}
const CLASS_0& FUNC_3() const CLASS_1
{
return info_;
}
OptionType type() const CLASS_1
{
return OptionType::ParamList;
}
private:
VAR_15 read(const std::VAR_8& VAR_16) VAR_14
{
if (!VAR_17){
VAR_11.clear();
VAR_17 = true;
}
const auto CLASS_3 = VAR_1::split(CLASS_2, ",");
for (const auto& part : VAR_18){
auto VAR_19 = convertFromString<VAR_4>(part);
FUNC_5 (!VAR_19)
VAR_20 false;
VAR_11.FUNC_6(*VAR_19);
}
hasValue_ = true;
return true;
}
bool FUNC_7() const VAR_14
{
return hasValue_;
}
bool FUNC_8() const VAR_14
{
return VAR_12.has_value();
}
std::VAR_8 FUNC_9() const FUNC_4
{
if (!VAR_12)
VAR_20 {};
auto VAR_21 = std::VAR_22{};
VAR_21 << "{";
auto VAR_23 = true;
for (VAR_24& VAR_25 : *VAR_12){
auto VAR_26 = FUNC_10(VAR_25);
if (!VAR_26)
VAR_20 {};
if (!VAR_23)
VAR_21 << ", ";
VAR_23 = false;
if (VAR_26->FUNC_11())
VAR_21 << "\"\"";
else
VAR_21 << *VAR_26;
}
VAR_21 << "}";
return VAR_21.FUNC_0();
}
private:
VAR_13 info_;
std::IMPORT_5<VAR_4>& VAR_11;
bool hasValue_ = false;
std::VAR_27<std::IMPORT_5<VAR_4>> VAR_12;
bool VAR_17 = false;
};
}
| 0.726657 | {'IMPORT_0': 'iparamlist.h', 'IMPORT_1': 'optioninfo.h', 'IMPORT_2': 'cmdlime/errors.h', 'IMPORT_3': 'cmdlime/customnames.h', 'IMPORT_4': 'cmdlime/stringconverter.h', 'IMPORT_5': 'vector', 'IMPORT_6': 'sstream', 'IMPORT_7': 'functional', 'VAR_0': 'detail', 'VAR_1': 'str', 'FUNC_0': 'str', 'VAR_2': 'string_utils', 'VAR_3': 'typename', 'VAR_4': 'T', 'VAR_5': 'class', 'VAR_6': 'public', 'VAR_7': 'IParamList', 'VAR_8': 'string', 'VAR_9': 'name', 'VAR_10': 'paramListValue', 'FUNC_1': 'move', 'FUNC_2': 'paramListValue_', 'VAR_11': 'paramListValue_', 'VAR_12': 'defaultValue_', 'VAR_13': 'OptionInfo', 'CLASS_0': 'OptionInfo', 'FUNC_3': 'info', 'VAR_14': 'override', 'CLASS_1': 'override', 'FUNC_4': 'override', 'VAR_15': 'bool', 'VAR_16': 'data', 'CLASS_2': 'data', 'VAR_17': 'isDefaultValueOverwritten_', 'CLASS_3': 'dataParts', 'VAR_18': 'dataParts', 'VAR_19': 'paramVal', 'FUNC_5': 'if', 'VAR_20': 'return', 'FUNC_6': 'emplace_back', 'FUNC_7': 'hasValue', 'FUNC_8': 'isOptional', 'FUNC_9': 'defaultValue', 'VAR_21': 'stream', 'VAR_22': 'stringstream', 'VAR_23': 'firstVal', 'VAR_24': 'auto', 'VAR_25': 'val', 'VAR_26': 'valStr', 'FUNC_10': 'convertToString', 'FUNC_11': 'empty', 'VAR_27': 'optional'} |
/*
* Copyright (C) 2009-2011 Texas Instruments, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <sosal/sosal.h>
#include <dvp/dvp.h>
#if defined(__QNX__)
#include <qnxscreen_api.h>
typedef struct _dvp_display_t {
struct qnxscreen_api *m_qnxscreen;
uint32_t width;
uint32_t height;
DVP_BOOL m_running;
DVP_Perf_t m_perf;
} dvp_display_t;
#define _DVP_DISPLAY_T
#include <dvp/dvp_display.h>
#include <dvp/dvp_mem.h>
#include <dvp/dvp_debug.h>
#define INITIAL_OFFSET_X (0)
#define INITIAL_OFFSET_Y (0)
DVP_BOOL DVP_Display_Alloc(dvp_display_t *dvpd, DVP_Image_t *pImage)
{
void *buffer = NULL;
uint32_t index = 0;
uint32_t length = 0;
if (!dvpd || !pImage)
return DVP_FALSE;
buffer = qnxscreen_acquire(dvpd->m_qnxscreen, &index);
if (!buffer)
return DVP_FALSE;
length = qnxscreen_length(dvpd->m_qnxscreen, index);
pImage->pBuffer[0] = buffer;
pImage->pData[0] = buffer;
switch (pImage->color) {
case FOURCC_NV12:
pImage->y_stride = length / (pImage->bufHeight + pImage->bufHeight/2);
pImage->pBuffer[1] = &pImage->pBuffer[0][(pImage->y_stride * pImage->bufHeight)];
pImage->pData[1] = pImage->pBuffer[1];
break;
case FOURCC_UYVY:
default:
pImage->y_stride = length / pImage->bufHeight; // we know it's strided.
break;
}
pImage->memType = DVP_MTYPE_DISPLAY_2DTILED;
pImage->numBytes = length;
DVP_PrintImage(DVP_ZONE_VIDEO, pImage);
return DVP_TRUE;
}
DVP_BOOL DVP_Display_Free(dvp_display_t *dvpd, DVP_Image_t *pImage)
{
void *buffer;
uint32_t index;
if (!dvpd || !pImage)
return DVP_FALSE;
buffer = pImage->pBuffer[0];
index = qnxscreen_search_buffer(dvpd->m_qnxscreen, buffer);
if (qnxscreen_release(dvpd->m_qnxscreen, buffer, index) == false_e)
return DVP_FALSE;
memset(pImage, 0, sizeof(DVP_Image_t));
pImage->memType = DVP_MTYPE_DEFAULT;
return DVP_TRUE;
}
void DVP_Display_Render(dvp_display_t *dvpd, DVP_Image_t *pImage)
{
uint32_t index = 0;
if (!dvpd || !pImage)
return;
DVP_PerformanceStart(&dvpd->m_perf);
DVP_PRINT(DVP_ZONE_VIDEO, "QNX Screen Rendering DVP_Image_t *%p Buffer %p\n", pImage, pImage->pBuffer[0]);
// get the index of the buffer
index = qnxscreen_search_buffer(dvpd->m_qnxscreen, pImage->pBuffer[0]);
if (index == QNXSCREEN_INVALID_INDEX) {
DVP_PRINT(DVP_ZONE_VIDEO, "ERROR: V4L2 Image is not allocated from display!\n");
return;
}
qnxscreen_post(dvpd->m_qnxscreen, index);
DVP_PerformanceStop(&dvpd->m_perf);
DVP_PerformancePrint(&dvpd->m_perf, "QNXSCREEN");
}
void DVP_Display_Destroy(dvp_display_t **dvpd)
{
if (!dvpd || !(*dvpd))
return;
qnxscreen_free((*dvpd)->m_qnxscreen); // unmap the memory
qnxscreen_close(&(*dvpd)->m_qnxscreen); // close the driver
free(*dvpd); // free the data structre
*dvpd = NULL; // set the user's pointer to null.
}
dvp_display_t *DVP_Display_Create(uint32_t image_width, uint32_t image_height,
uint32_t buffer_width, uint32_t buffer_height,
uint32_t display_width, uint32_t display_height,
uint32_t scaled_width, uint32_t scaled_height,
uint32_t crop_top, uint32_t crop_left,
fourcc_t color, int32_t rotation, uint32_t numBuffers)
{
dvp_display_t *dvpd = (dvp_display_t *)calloc(1,sizeof(dvp_display_t));
uint32_t overlay_width = 0;
uint32_t overlay_height = 0;
// @TODO: figure out a better way to handle this for rotation
uint32_t offset_x = 15;
uint32_t offset_y = 600-(image_height+15);
if (!dvpd)
return NULL;
DVP_PRINT(DVP_ZONE_VIDEO, "Image: %ux%u Display: %ux%u Scaled:%ux%u\n",
image_width, image_height,
display_width, display_height,
scaled_width, scaled_height);
dvpd->m_qnxscreen = qnxscreen_open();
dvpd->width = image_width;
dvpd->height = image_height;
DVP_Perf_Clear(&dvpd->m_perf);
if (qnxscreen_allocate(dvpd->m_qnxscreen, buffer_width, buffer_height, numBuffers, color) == false_e)
goto unwind;
// retrieve the information about the overlay
qnxscreen_metrics(dvpd->m_qnxscreen, &overlay_width, &overlay_height);
DVP_PRINT(DVP_ZONE_VIDEO, "OVERLAY: %ux%u %ux%u\n", overlay_width, overlay_height, display_width, display_height);
if (offset_x > (display_width-scaled_width))
offset_x = (display_width-scaled_width);
if (offset_y > (display_height-scaled_height))
offset_y = (display_height-scaled_height);
qnxscreen_mirror(dvpd->m_qnxscreen, true_e);
qnxscreen_transparency(dvpd->m_qnxscreen, 100);
qnxscreen_position(dvpd->m_qnxscreen, offset_x, offset_y, scaled_width, scaled_height);
// set the rotation of the overlay.
qnxscreen_rotate(dvpd->m_qnxscreen, rotation);
// insert a green/gray screen at the start
{
DVP_Image_t tmp;
uint32_t y, i;
DVP_Image_Init(&tmp, buffer_width, buffer_width, color);
tmp.width = image_width;
tmp.height = image_height;
DVP_Display_Alloc(dvpd, &tmp);
if (color == FOURCC_UYVY) {
for (y = 0; y < tmp.height; y++) {
i = (y * tmp.y_stride);
memset(&tmp.pData[0][i], 0x80, tmp.width * 2);
}
} else if (color == FOURCC_NV12) {
for (y = 0; y < tmp.height; y++) {
i = (y * tmp.y_stride);
memset(&tmp.pData[0][i], 0x80,
tmp.width * tmp.x_stride);
}
for (y = 0; y < tmp.height; y++) {
i = (y/2 * tmp.y_stride);
memset(&tmp.pData[1][i], 0x10,
tmp.width / 2 * tmp.x_stride * 2);
}
}
DVP_Display_Render(dvpd, &tmp); // this will do a memcpy
DVP_Display_Free(dvpd, &tmp);
}
return dvpd;
unwind:
DVP_Display_Destroy(&dvpd);
return NULL;
}
DVP_BOOL DVP_Display_Drop(dvp_display_t *dvpd, DVP_Image_t *pImage)
{
if (dvpd && pImage)
return DVP_TRUE;
else
return DVP_FALSE;
}
#endif
| /*
* Copyright (C) 2009-2011 Texas Instruments, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <sosal/sosal.h>
#include <dvp/dvp.h>
#if defined(__QNX__)
#include <IMPORT_0>
typedef struct _dvp_display_t {
struct qnxscreen_api *VAR_0;
uint32_t width;
uint32_t VAR_1;
DVP_BOOL m_running;
DVP_Perf_t m_perf;
} dvp_display_t;
#define _DVP_DISPLAY_T
#include <IMPORT_1>
#include <IMPORT_2>
#include <IMPORT_3>
#define INITIAL_OFFSET_X (0)
#define VAR_2 (0)
DVP_BOOL FUNC_0(dvp_display_t *dvpd, CLASS_0 *pImage)
{
void *buffer = NULL;
uint32_t VAR_4 = 0;
uint32_t VAR_5 = 0;
if (!dvpd || !pImage)
return DVP_FALSE;
buffer = qnxscreen_acquire(dvpd->VAR_0, &VAR_4);
if (!buffer)
return DVP_FALSE;
VAR_5 = FUNC_1(dvpd->VAR_0, VAR_4);
pImage->pBuffer[0] = buffer;
pImage->VAR_6[0] = buffer;
switch (pImage->VAR_7) {
case FOURCC_NV12:
pImage->VAR_8 = VAR_5 / (pImage->bufHeight + pImage->bufHeight/2);
pImage->pBuffer[1] = &pImage->pBuffer[0][(pImage->VAR_8 * pImage->bufHeight)];
pImage->VAR_6[1] = pImage->pBuffer[1];
break;
case FOURCC_UYVY:
default:
pImage->VAR_8 = VAR_5 / pImage->bufHeight; // we know it's strided.
break;
}
pImage->VAR_9 = VAR_10;
pImage->numBytes = VAR_5;
DVP_PrintImage(VAR_11, pImage);
return DVP_TRUE;
}
DVP_BOOL DVP_Display_Free(dvp_display_t *dvpd, CLASS_0 *pImage)
{
void *buffer;
uint32_t VAR_4;
if (!dvpd || !pImage)
return DVP_FALSE;
buffer = pImage->pBuffer[0];
VAR_4 = FUNC_2(dvpd->VAR_0, buffer);
if (qnxscreen_release(dvpd->VAR_0, buffer, VAR_4) == VAR_12)
return DVP_FALSE;
memset(pImage, 0, sizeof(VAR_3));
pImage->VAR_9 = VAR_13;
return DVP_TRUE;
}
void DVP_Display_Render(dvp_display_t *dvpd, CLASS_0 *pImage)
{
uint32_t VAR_4 = 0;
if (!dvpd || !pImage)
return;
DVP_PerformanceStart(&dvpd->m_perf);
DVP_PRINT(VAR_11, "QNX Screen Rendering DVP_Image_t *%p Buffer %p\n", pImage, pImage->pBuffer[0]);
// get the index of the buffer
VAR_4 = FUNC_2(dvpd->VAR_0, pImage->pBuffer[0]);
if (VAR_4 == VAR_14) {
DVP_PRINT(VAR_11, "ERROR: V4L2 Image is not allocated from display!\n");
return;
}
qnxscreen_post(dvpd->VAR_0, VAR_4);
DVP_PerformanceStop(&dvpd->m_perf);
DVP_PerformancePrint(&dvpd->m_perf, "QNXSCREEN");
}
void FUNC_3(dvp_display_t **dvpd)
{
if (!dvpd || !(*dvpd))
return;
qnxscreen_free((*dvpd)->VAR_0); // unmap the memory
qnxscreen_close(&(*dvpd)->VAR_0); // close the driver
free(*dvpd); // free the data structre
*dvpd = NULL; // set the user's pointer to null.
}
dvp_display_t *DVP_Display_Create(uint32_t image_width, uint32_t image_height,
uint32_t VAR_15, uint32_t buffer_height,
uint32_t VAR_16, uint32_t display_height,
uint32_t scaled_width, uint32_t scaled_height,
uint32_t VAR_17, uint32_t VAR_18,
fourcc_t VAR_7, int32_t rotation, uint32_t VAR_19)
{
dvp_display_t *dvpd = (dvp_display_t *)calloc(1,sizeof(dvp_display_t));
uint32_t VAR_20 = 0;
uint32_t overlay_height = 0;
// @TODO: figure out a better way to handle this for rotation
uint32_t offset_x = 15;
uint32_t offset_y = 600-(image_height+15);
if (!dvpd)
return NULL;
DVP_PRINT(VAR_11, "Image: %ux%u Display: %ux%u Scaled:%ux%u\n",
image_width, image_height,
VAR_16, display_height,
scaled_width, scaled_height);
dvpd->VAR_0 = FUNC_4();
dvpd->width = image_width;
dvpd->VAR_1 = image_height;
FUNC_5(&dvpd->m_perf);
if (qnxscreen_allocate(dvpd->VAR_0, VAR_15, buffer_height, VAR_19, VAR_7) == VAR_12)
goto unwind;
// retrieve the information about the overlay
qnxscreen_metrics(dvpd->VAR_0, &VAR_20, &overlay_height);
DVP_PRINT(VAR_11, "OVERLAY: %ux%u %ux%u\n", VAR_20, overlay_height, VAR_16, display_height);
if (offset_x > (VAR_16-scaled_width))
offset_x = (VAR_16-scaled_width);
if (offset_y > (display_height-scaled_height))
offset_y = (display_height-scaled_height);
FUNC_6(dvpd->VAR_0, VAR_21);
FUNC_7(dvpd->VAR_0, 100);
qnxscreen_position(dvpd->VAR_0, offset_x, offset_y, scaled_width, scaled_height);
// set the rotation of the overlay.
qnxscreen_rotate(dvpd->VAR_0, rotation);
// insert a green/gray screen at the start
{
CLASS_0 tmp;
uint32_t VAR_22, i;
FUNC_8(&tmp, VAR_15, VAR_15, VAR_7);
tmp.width = image_width;
tmp.VAR_1 = image_height;
FUNC_0(dvpd, &tmp);
if (VAR_7 == FOURCC_UYVY) {
for (VAR_22 = 0; VAR_22 < tmp.VAR_1; VAR_22++) {
i = (VAR_22 * tmp.VAR_8);
memset(&tmp.VAR_6[0][i], 0x80, tmp.width * 2);
}
} else if (VAR_7 == FOURCC_NV12) {
for (VAR_22 = 0; VAR_22 < tmp.VAR_1; VAR_22++) {
i = (VAR_22 * tmp.VAR_8);
memset(&tmp.VAR_6[0][i], 0x80,
tmp.width * tmp.VAR_23);
}
for (VAR_22 = 0; VAR_22 < tmp.VAR_1; VAR_22++) {
i = (VAR_22/2 * tmp.VAR_8);
memset(&tmp.VAR_6[1][i], 0x10,
tmp.width / 2 * tmp.VAR_23 * 2);
}
}
DVP_Display_Render(dvpd, &tmp); // this will do a memcpy
DVP_Display_Free(dvpd, &tmp);
}
return dvpd;
unwind:
FUNC_3(&dvpd);
return NULL;
}
DVP_BOOL DVP_Display_Drop(dvp_display_t *dvpd, CLASS_0 *pImage)
{
if (dvpd && pImage)
return DVP_TRUE;
else
return DVP_FALSE;
}
#endif
| 0.434496 | {'IMPORT_0': 'qnxscreen_api.h', 'VAR_0': 'm_qnxscreen', 'VAR_1': 'height', 'IMPORT_1': 'dvp/dvp_display.h', 'IMPORT_2': 'dvp/dvp_mem.h', 'IMPORT_3': 'dvp/dvp_debug.h', 'VAR_2': 'INITIAL_OFFSET_Y', 'FUNC_0': 'DVP_Display_Alloc', 'CLASS_0': 'DVP_Image_t', 'VAR_3': 'DVP_Image_t', 'VAR_4': 'index', 'VAR_5': 'length', 'FUNC_1': 'qnxscreen_length', 'VAR_6': 'pData', 'VAR_7': 'color', 'VAR_8': 'y_stride', 'VAR_9': 'memType', 'VAR_10': 'DVP_MTYPE_DISPLAY_2DTILED', 'VAR_11': 'DVP_ZONE_VIDEO', 'FUNC_2': 'qnxscreen_search_buffer', 'VAR_12': 'false_e', 'VAR_13': 'DVP_MTYPE_DEFAULT', 'VAR_14': 'QNXSCREEN_INVALID_INDEX', 'FUNC_3': 'DVP_Display_Destroy', 'VAR_15': 'buffer_width', 'VAR_16': 'display_width', 'VAR_17': 'crop_top', 'VAR_18': 'crop_left', 'VAR_19': 'numBuffers', 'VAR_20': 'overlay_width', 'FUNC_4': 'qnxscreen_open', 'FUNC_5': 'DVP_Perf_Clear', 'FUNC_6': 'qnxscreen_mirror', 'VAR_21': 'true_e', 'FUNC_7': 'qnxscreen_transparency', 'VAR_22': 'y', 'FUNC_8': 'DVP_Image_Init', 'VAR_23': 'x_stride'} |
struct s { unsigned int bit1 :1; unsigned int bit4 :4;};
union u { struct s ans; int i; };
typedef union u bits;
int callee (bits b){
return b.ans.bit1 ? 3 : 4;
}
int main (int argc, int *argv[]){
bits b;
b.i = 5;
return callee(b);
}
| struct CLASS_0 { unsigned int VAR_0 :1; unsigned int bit4 :4;};
union CLASS_1 { struct CLASS_0 ans; int VAR_1; };
typedef union CLASS_1 ID_0;
int FUNC_0 (CLASS_2 VAR_2){
return VAR_2.ans.VAR_0 ? 3 : 4;
}
int FUNC_1 (int VAR_3, int *VAR_4[]){
CLASS_2 VAR_2;
VAR_2.VAR_1 = 5;
return FUNC_0(VAR_2);
}
| 0.879755 | {'CLASS_0': 's', 'VAR_0': 'bit1', 'CLASS_1': 'u', 'VAR_1': 'i', 'ID_0': 'bits', 'CLASS_2': 'bits', 'FUNC_0': 'callee', 'VAR_2': 'b', 'FUNC_1': 'main', 'VAR_3': 'argc', 'VAR_4': 'argv'} |
/*-
* Copyright (c) 2016 <NAME> <<EMAIL>>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* Pin multiplexer driver for Tegra SoCs.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/malloc.h>
#include <sys/rman.h>
#include <machine/bus.h>
#include <machine/fdt.h>
#include <dev/fdt/fdt_common.h>
#include <dev/fdt/fdt_pinctrl.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
/* Pin multipexor register. */
#define TEGRA_MUX_FUNCTION_MASK 0x03
#define TEGRA_MUX_FUNCTION_SHIFT 0
#define TEGRA_MUX_PUPD_MASK 0x03
#define TEGRA_MUX_PUPD_SHIFT 2
#define TEGRA_MUX_TRISTATE_SHIFT 4
#define TEGRA_MUX_ENABLE_INPUT_SHIFT 5
#define TEGRA_MUX_OPEN_DRAIN_SHIFT 6
#define TEGRA_MUX_LOCK_SHIFT 7
#define TEGRA_MUX_IORESET_SHIFT 8
#define TEGRA_MUX_RCV_SEL_SHIFT 9
/* Pin goup register. */
#define TEGRA_GRP_HSM_SHIFT 2
#define TEGRA_GRP_SCHMT_SHIFT 3
#define TEGRA_GRP_DRV_TYPE_SHIFT 6
#define TEGRA_GRP_DRV_TYPE_MASK 0x03
#define TEGRA_GRP_DRV_DRVDN_SLWR_SHIFT 28
#define TEGRA_GRP_DRV_DRVDN_SLWR_MASK 0x03
#define TEGRA_GRP_DRV_DRVUP_SLWF_SHIFT 30
#define TEGRA_GRP_DRV_DRVUP_SLWF_MASK 0x03
struct pinmux_softc {
device_t dev;
struct resource *pad_mem_res;
struct resource *mux_mem_res;
struct resource *mipi_mem_res;
};
static struct ofw_compat_data compat_data[] = {
{"nvidia,tegra124-pinmux", 1},
{NULL, 0},
};
enum prop_id {
PROP_ID_PULL,
PROP_ID_TRISTATE,
PROP_ID_ENABLE_INPUT,
PROP_ID_OPEN_DRAIN,
PROP_ID_LOCK,
PROP_ID_IORESET,
PROP_ID_RCV_SEL,
PROP_ID_HIGH_SPEED_MODE,
PROP_ID_SCHMITT,
PROP_ID_LOW_POWER_MODE,
PROP_ID_DRIVE_DOWN_STRENGTH,
PROP_ID_DRIVE_UP_STRENGTH,
PROP_ID_SLEW_RATE_FALLING,
PROP_ID_SLEW_RATE_RISING,
PROP_ID_DRIVE_TYPE,
PROP_ID_MAX_ID
};
/* Numeric based parameters. */
static const struct prop_name {
const char *name;
enum prop_id id;
} prop_names[] = {
{"nvidia,pull", PROP_ID_PULL},
{"nvidia,tristate", PROP_ID_TRISTATE},
{"nvidia,enable-input", PROP_ID_ENABLE_INPUT},
{"nvidia,open-drain", PROP_ID_OPEN_DRAIN},
{"nvidia,lock", PROP_ID_LOCK},
{"nvidia,io-reset", PROP_ID_IORESET},
{"nvidia,rcv-sel", PROP_ID_RCV_SEL},
{"nvidia,high-speed-mode", PROP_ID_HIGH_SPEED_MODE},
{"nvidia,schmitt", PROP_ID_SCHMITT},
{"nvidia,low-power-mode", PROP_ID_LOW_POWER_MODE},
{"nvidia,pull-down-strength", PROP_ID_DRIVE_DOWN_STRENGTH},
{"nvidia,pull-up-strength", PROP_ID_DRIVE_UP_STRENGTH},
{"nvidia,slew-rate-falling", PROP_ID_SLEW_RATE_FALLING},
{"nvidia,slew-rate-rising", PROP_ID_SLEW_RATE_RISING},
{"nvidia,drive-type", PROP_ID_DRIVE_TYPE},
};
/*
* configuration for one pin group.
*/
struct pincfg {
char *function;
int params[PROP_ID_MAX_ID];
};
#define GPIO_BANK_A 0
#define GPIO_BANK_B 1
#define GPIO_BANK_C 2
#define GPIO_BANK_D 3
#define GPIO_BANK_E 4
#define GPIO_BANK_F 5
#define GPIO_BANK_G 6
#define GPIO_BANK_H 7
#define GPIO_BANK_I 8
#define GPIO_BANK_J 9
#define GPIO_BANK_K 10
#define GPIO_BANK_L 11
#define GPIO_BANK_M 12
#define GPIO_BANK_N 13
#define GPIO_BANK_O 14
#define GPIO_BANK_P 15
#define GPIO_BANK_Q 16
#define GPIO_BANK_R 17
#define GPIO_BANK_S 18
#define GPIO_BANK_T 19
#define GPIO_BANK_U 20
#define GPIO_BANK_V 21
#define GPIO_BANK_W 22
#define GPIO_BANK_X 23
#define GPIO_BANK_Y 24
#define GPIO_BANK_Z 25
#define GPIO_BANK_AA 26
#define GPIO_BANK_BB 27
#define GPIO_BANK_CC 28
#define GPIO_BANK_DD 29
#define GPIO_BANK_EE 30
#define GPIO_BANK_FF 31
#define GPIO_NUM(b, p) (8 * (b) + (p))
struct tegra_mux {
char *name;
bus_size_t reg;
char *functions[4];
int gpio_num;
};
#define GMUX(r, gb, gi, nm, f1, f2, f3, f4) \
{ \
.name = #nm, \
.reg = r, \
.gpio_num = GPIO_NUM(GPIO_BANK_##gb, gi), \
.functions = {#f1, #f2, #f3, #f4}, \
}
#define FMUX(r, nm, f1, f2, f3, f4) \
{ \
.name = #nm, \
.reg = r, \
.gpio_num = -1, \
.functions = {#f1, #f2, #f3, #f4}, \
}
static const struct tegra_mux pin_mux_tbl[] = {
GMUX(0x000, O, 1, ulpi_data0_po1, spi3, hsi, uarta, ulpi),
GMUX(0x004, O, 2, ulpi_data1_po2, spi3, hsi, uarta, ulpi),
GMUX(0x008, O, 3, ulpi_data2_po3, spi3, hsi, uarta, ulpi),
GMUX(0x00C, O, 4, ulpi_data3_po4, spi3, hsi, uarta, ulpi),
GMUX(0x010, O, 5, ulpi_data4_po5, spi2, hsi, uarta, ulpi),
GMUX(0x014, O, 6, ulpi_data5_po6, spi2, hsi, uarta, ulpi),
GMUX(0x018, O, 7, ulpi_data6_po7, spi2, hsi, uarta, ulpi),
GMUX(0x01C, O, 0, ulpi_data7_po0, spi2, hsi, uarta, ulpi),
GMUX(0x020, P, 9, ulpi_clk_py0, spi1, spi5, uartd, ulpi),
GMUX(0x024, P, 1, ulpi_dir_py1, spi1, spi5, uartd, ulpi),
GMUX(0x028, P, 2, ulpi_nxt_py2, spi1, spi5, uartd, ulpi),
GMUX(0x02C, P, 3, ulpi_stp_py3, spi1, spi5, uartd, ulpi),
GMUX(0x030, P, 0, dap3_fs_pp0, i2s2, spi5, displaya, displayb),
GMUX(0x034, P, 1, dap3_din_pp1, i2s2, spi5, displaya, displayb),
GMUX(0x038, P, 2, dap3_dout_pp2, i2s2, spi5, displaya, rsvd4),
GMUX(0x03C, P, 3, dap3_sclk_pp3, i2s2, spi5, rsvd3, displayb),
GMUX(0x040, V, 0, pv0, rsvd1, rsvd2, rsvd3, rsvd4),
GMUX(0x044, V, 1, pv1, rsvd1, rsvd2, rsvd3, rsvd4),
GMUX(0x048, Z, 0, sdmmc1_clk_pz0, sdmmc1, clk12, rsvd3, rsvd4),
GMUX(0x04C, Z, 1, sdmmc1_cmd_pz1, sdmmc1, spdif, spi4, uarta),
GMUX(0x050, Y, 4, sdmmc1_dat3_py4, sdmmc1, spdif, spi4, uarta),
GMUX(0x054, Y, 5, sdmmc1_dat2_py5, sdmmc1, pwm0, spi4, uarta),
GMUX(0x058, Y, 6, sdmmc1_dat1_py6, sdmmc1, pwm1, spi4, uarta),
GMUX(0x05C, Y, 7, sdmmc1_dat0_py7, sdmmc1, rsvd2, spi4, uarta),
GMUX(0x068, W, 5, clk2_out_pw5, extperiph2, rsvd2, rsvd3, rsvd4),
GMUX(0x06C, CC, 5, clk2_req_pcc5, dap, rsvd2, rsvd3, rsvd4),
GMUX(0x110, N, 7, hdmi_int_pn7, rsvd1, rsvd2, rsvd3, rsvd4),
GMUX(0x114, V, 4, ddc_scl_pv4, i2c4, rsvd2, rsvd3, rsvd4),
GMUX(0x118, V, 5, ddc_sda_pv5, i2c4, rsvd2, rsvd3, rsvd4),
GMUX(0x164, V, 3, uart2_rxd_pc3, irda, spdif, uarta, spi4),
GMUX(0x168, C, 2, uart2_txd_pc2, irda, spdif, uarta, spi4),
GMUX(0x16C, J, 6, uart2_rts_n_pj6, uarta, uartb, gmi, spi4),
GMUX(0x170, J, 5, uart2_cts_n_pj5, uarta, uartb, gmi, spi4),
GMUX(0x174, W, 6, uart3_txd_pw6, uartc, rsvd2, gmi, spi4),
GMUX(0x178, W, 7, uart3_rxd_pw7, uartc, rsvd2, gmi, spi4),
GMUX(0x17C, S, 1, uart3_cts_n_pa1, uartc, sdmmc1, dtv, gmi),
GMUX(0x180, C, 0, uart3_rts_n_pc0, uartc, pwm0, dtv, gmi),
GMUX(0x184, U, 0, pu0, owr, uarta, gmi, rsvd4),
GMUX(0x188, U, 1, pu1, rsvd1, uarta, gmi, rsvd4),
GMUX(0x18C, U, 2, pu2, rsvd1, uarta, gmi, rsvd4),
GMUX(0x190, U, 3, pu3, pwm0, uarta, gmi, displayb),
GMUX(0x194, U, 4, pu4, pwm1, uarta, gmi, displayb),
GMUX(0x198, U, 5, pu5, pwm2, uarta, gmi, displayb),
GMUX(0x19C, U, 6, pu6, pwm3, uarta, rsvd3, gmi),
GMUX(0x1A0, C, 5, gen1_i2c_sda_pc5, i2c1, rsvd2, rsvd3, rsvd4),
GMUX(0x1A4, C, 4, gen1_i2c_scl_pc4, i2c1, rsvd2, rsvd3, rsvd4),
GMUX(0x1A8, P, 3, dap4_fs_pp4, i2s3, gmi, dtv, rsvd4),
GMUX(0x1AC, P, 4, dap4_din_pp5, i2s3, gmi, rsvd3, rsvd4),
GMUX(0x1B0, P, 5, dap4_dout_pp6, i2s3, gmi, dtv, rsvd4),
GMUX(0x1B4, P, 7, dap4_sclk_pp7, i2s3, gmi, rsvd3, rsvd4),
GMUX(0x1B8, P, 0, clk3_out_pee0, extperiph3, rsvd2, rsvd3, rsvd4),
GMUX(0x1BC, EE, 1, clk3_req_pee1, dev3, rsvd2, rsvd3, rsvd4),
GMUX(0x1C0, C, 7, pc7, rsvd1, rsvd2, gmi, gmi_alt),
GMUX(0x1C4, I, 5, pi5, sdmmc2, rsvd2, gmi, rsvd4),
GMUX(0x1C8, I, 7, pi7, rsvd1, trace, gmi, dtv),
GMUX(0x1CC, K, 0, pk0, rsvd1, sdmmc3, gmi, soc),
GMUX(0x1D0, K, 1, pk1, sdmmc2, trace, gmi, rsvd4),
GMUX(0x1D4, J, 0, pj0, rsvd1, rsvd2, gmi, usb),
GMUX(0x1D8, J, 2, pj2, rsvd1, rsvd2, gmi, soc),
GMUX(0x1DC, K, 3, pk3, sdmmc2, trace, gmi, ccla),
GMUX(0x1E0, K, 4, pk4, sdmmc2, rsvd2, gmi, gmi_alt),
GMUX(0x1E4, K, 2, pk2, rsvd1, rsvd2, gmi, rsvd4),
GMUX(0x1E8, I, 3, pi3, rsvd1, rsvd2, gmi, spi4),
GMUX(0x1EC, I, 6, pi6, rsvd1, rsvd2, gmi, sdmmc2),
GMUX(0x1F0, G, 0, pg0, rsvd1, rsvd2, gmi, rsvd4),
GMUX(0x1F4, G, 1, pg1, rsvd1, rsvd2, gmi, rsvd4),
GMUX(0x1F8, G, 2, pg2, rsvd1, trace, gmi, rsvd4),
GMUX(0x1FC, G, 3, pg3, rsvd1, trace, gmi, rsvd4),
GMUX(0x200, G, 4, pg4, rsvd1, tmds, gmi, spi4),
GMUX(0x204, G, 5, pg5, rsvd1, rsvd2, gmi, spi4),
GMUX(0x208, G, 6, pg6, rsvd1, rsvd2, gmi, spi4),
GMUX(0x20C, G, 7, pg7, rsvd1, rsvd2, gmi, spi4),
GMUX(0x210, H, 0, ph0, pwm0, trace, gmi, dtv),
GMUX(0x214, H, 1, ph1, pwm1, tmds, gmi, displaya),
GMUX(0x218, H, 2, ph2, pwm2, tmds, gmi, cldvfs),
GMUX(0x21C, H, 3, ph3, pwm3, spi4, gmi, cldvfs),
GMUX(0x220, H, 4, ph4, sdmmc2, rsvd2, gmi, rsvd4),
GMUX(0x224, H, 5, ph5, sdmmc2, rsvd2, gmi, rsvd4),
GMUX(0x228, H, 6, ph6, sdmmc2, trace, gmi, dtv),
GMUX(0x22C, H, 7, ph7, sdmmc2, trace, gmi, dtv),
GMUX(0x230, J, 7, pj7, uartd, rsvd2, gmi, gmi_alt),
GMUX(0x234, B, 0, pb0, uartd, rsvd2, gmi, rsvd4),
GMUX(0x238, B, 1, pb1, uartd, rsvd2, gmi, rsvd4),
GMUX(0x23C, K, 7, pk7, uartd, rsvd2, gmi, rsvd4),
GMUX(0x240, I, 0, pi0, rsvd1, rsvd2, gmi, rsvd4),
GMUX(0x244, I, 1, pi1, rsvd1, rsvd2, gmi, rsvd4),
GMUX(0x248, I, 2, pi2, sdmmc2, trace, gmi, rsvd4),
GMUX(0x24C, I, 4, pi4, spi4, trace, gmi, displaya),
GMUX(0x250, T, 5, gen2_i2c_scl_pt5, i2c2, rsvd2, gmi, rsvd4),
GMUX(0x254, T, 6, gen2_i2c_sda_pt6, i2c2, rsvd2, gmi, rsvd4),
GMUX(0x258, CC, 4, sdmmc4_clk_pcc4, sdmmc4, rsvd2, gmi, rsvd4),
GMUX(0x25C, T, 7, sdmmc4_cmd_pt7, sdmmc4, rsvd2, gmi, rsvd4),
GMUX(0x260, AA, 0, sdmmc4_dat0_paa0, sdmmc4, spi3, gmi, rsvd4),
GMUX(0x264, AA, 1, sdmmc4_dat1_paa1, sdmmc4, spi3, gmi, rsvd4),
GMUX(0x268, AA, 2, sdmmc4_dat2_paa2, sdmmc4, spi3, gmi, rsvd4),
GMUX(0x26C, AA, 3, sdmmc4_dat3_paa3, sdmmc4, spi3, gmi, rsvd4),
GMUX(0x270, AA, 4, sdmmc4_dat4_paa4, sdmmc4, spi3, gmi, rsvd4),
GMUX(0x274, AA, 5, sdmmc4_dat5_paa5, sdmmc4, spi3, rsvd3, rsvd4),
GMUX(0x278, AA, 6, sdmmc4_dat6_paa6, sdmmc4, spi3, gmi, rsvd4),
GMUX(0x27C, AA, 7, sdmmc4_dat7_paa7, sdmmc4, rsvd2, gmi, rsvd4),
GMUX(0x284, CC, 0, cam_mclk_pcc0, vi, vi_alt1, vi_alt3, sdmmc2),
GMUX(0x288, CC, 1, pcc1, i2s4, rsvd2, rsvd3, sdmmc2),
GMUX(0x28C, BB, 0, pbb0, vgp6, vimclk2, sdmmc2, vimclk2_alt),
GMUX(0x290, BB, 1, cam_i2c_scl_pbb1, vgp1, i2c3, rsvd3, sdmmc2),
GMUX(0x294, BB, 2, cam_i2c_sda_pbb2, vgp2, i2c3, rsvd3, sdmmc2),
GMUX(0x298, BB, 3, pbb3, vgp3, displaya, displayb, sdmmc2),
GMUX(0x29C, BB, 4, pbb4, vgp4, displaya, displayb, sdmmc2),
GMUX(0x2A0, BB, 5, pbb5, vgp5, displaya, rsvd3, sdmmc2),
GMUX(0x2A4, BB, 6, pbb6, i2s4, rsvd2, displayb, sdmmc2),
GMUX(0x2A8, BB, 7, pbb7, i2s4, rsvd2, rsvd3, sdmmc2),
GMUX(0x2AC, CC, 2, pcc2, i2s4, rsvd2, sdmmc3, sdmmc2),
FMUX(0x2B0, jtag_rtck, rtck, rsvd2, rsvd3, rsvd4),
GMUX(0x2B4, Z, 6, pwr_i2c_scl_pz6, i2cpwr, rsvd2, rsvd3, rsvd4),
GMUX(0x2B8, Z, 7, pwr_i2c_sda_pz7, i2cpwr, rsvd2, rsvd3, rsvd4),
GMUX(0x2BC, R, 0, kb_row0_pr0, kbc, rsvd2, rsvd3, rsvd4),
GMUX(0x2C0, R, 1, kb_row1_pr1, kbc, rsvd2, rsvd3, rsvd4),
GMUX(0x2C4, R, 2, kb_row2_pr2, kbc, rsvd2, rsvd3, rsvd4),
GMUX(0x2C8, R, 3, kb_row3_pr3, kbc, displaya, sys, displayb),
GMUX(0x2CC, R, 4, kb_row4_pr4, kbc, displaya, rsvd3, displayb),
GMUX(0x2D0, R, 5, kb_row5_pr5, kbc, displaya, rsvd3, displayb),
GMUX(0x2D4, R, 6, kb_row6_pr6, kbc, displaya, displaya_alt, displayb),
GMUX(0x2D8, R, 7, kb_row7_pr7, kbc, rsvd2, cldvfs, uarta),
GMUX(0x2DC, S, 0, kb_row8_ps0, kbc, rsvd2, cldvfs, uarta),
GMUX(0x2E0, S, 1, kb_row9_ps1, kbc, rsvd2, rsvd3, uarta),
GMUX(0x2E4, S, 2, kb_row10_ps2, kbc, rsvd2, rsvd3, uarta),
GMUX(0x2E8, S, 3, kb_row11_ps3, kbc, rsvd2, rsvd3, irda),
GMUX(0x2EC, S, 4, kb_row12_ps4, kbc, rsvd2, rsvd3, irda),
GMUX(0x2F0, S, 5, kb_row13_ps5, kbc, rsvd2, spi2, rsvd4),
GMUX(0x2F4, S, 6, kb_row14_ps6, kbc, rsvd2, spi2, rsvd4),
GMUX(0x2F8, S, 7, kb_row15_ps7, kbc, soc, rsvd3, rsvd4),
GMUX(0x2FC, Q, 0, kb_col0_pq0, kbc, rsvd2, spi2, rsvd4),
GMUX(0x300, Q, 1, kb_col1_pq1, kbc, rsvd2, spi2, rsvd4),
GMUX(0x304, Q, 2, kb_col2_pq2, kbc, rsvd2, spi2, rsvd4),
GMUX(0x308, Q, 3, kb_col3_pq3, kbc, displaya, pwm2, uarta),
GMUX(0x30C, Q, 4, kb_col4_pq4, kbc, owr, sdmmc3, uarta),
GMUX(0x310, Q, 5, kb_col5_pq5, kbc, rsvd2, sdmmc3, rsvd4),
GMUX(0x314, Q, 6, kb_col6_pq6, kbc, rsvd2, spi2, uartd),
GMUX(0x318, Q, 7, kb_col7_pq7, kbc, rsvd2, spi2, uartd),
GMUX(0x31C, A, 0, clk_32k_out_pa0, blink, soc, rsvd3, rsvd4),
FMUX(0x324, core_pwr_req, pwron, rsvd2, rsvd3, rsvd4),
FMUX(0x328, cpu_pwr_req, cpu, rsvd2, rsvd3, rsvd4),
FMUX(0x32C, pwr_int_n, pmi, rsvd2, rsvd3, rsvd4),
FMUX(0x330, clk_32k_in, clk, rsvd2, rsvd3, rsvd4),
FMUX(0x334, owr, owr, rsvd2, rsvd3, rsvd4),
GMUX(0x338, N, 0, dap1_fs_pn0, i2s0, hda, gmi, rsvd4),
GMUX(0x33C, N, 1, dap1_din_pn1, i2s0, hda, gmi, rsvd4),
GMUX(0x340, N, 2, dap1_dout_pn2, i2s0, hda, gmi, sata),
GMUX(0x344, N, 3, dap1_sclk_pn3, i2s0, hda, gmi, rsvd4),
GMUX(0x348, EE, 2, dap_mclk1_req_pee2, dap, dap1, sata, rsvd4),
GMUX(0x34C, W, 4, dap_mclk1_pw4, extperiph1, dap2, rsvd3, rsvd4),
GMUX(0x350, K, 6, spdif_in_pk6, spdif, rsvd2, rsvd3, i2c3),
GMUX(0x354, K, 5, spdif_out_pk5, spdif, rsvd2, rsvd3, i2c3),
GMUX(0x358, A, 2, dap2_fs_pa2, i2s1, hda, gmi, rsvd4),
GMUX(0x35C, A, 4, dap2_din_pa4, i2s1, hda, gmi, rsvd4),
GMUX(0x360, A, 5, dap2_dout_pa5, i2s1, hda, gmi, rsvd4),
GMUX(0x364, A, 3, dap2_sclk_pa3, i2s1, hda, gmi, rsvd4),
GMUX(0x368, X, 0, dvfs_pwm_px0, spi6, cldvfs, gmi, rsvd4),
GMUX(0x36C, X, 1, gpio_x1_aud_px1, spi6, rsvd2, gmi, rsvd4),
GMUX(0x370, X, 3, gpio_x3_aud_px3, spi6, spi1, gmi, rsvd4),
GMUX(0x374, X, 2, dvfs_clk_px2, spi6, cldvfs, gmi, rsvd4),
GMUX(0x378, X, 4, gpio_x4_aud_px4, gmi, spi1, spi2, dap2),
GMUX(0x37C, X, 5, gpio_x5_aud_px5, gmi, spi1, spi2, rsvd4),
GMUX(0x380, X, 6, gpio_x6_aud_px6, spi6, spi1, spi2, gmi),
GMUX(0x384, X, 7, gpio_x7_aud_px7, rsvd1, spi1, spi2, rsvd4),
GMUX(0x390, A, 6, sdmmc3_clk_pa6, sdmmc3, rsvd2, rsvd3, spi3),
GMUX(0x394, A, 7, sdmmc3_cmd_pa7, sdmmc3, pwm3, uarta, spi3),
GMUX(0x398, B, 7, sdmmc3_dat0_pb7, sdmmc3, rsvd2, rsvd3, spi3),
GMUX(0x39C, B, 6, sdmmc3_dat1_pb6, sdmmc3, pwm2, uarta, spi3),
GMUX(0x3A0, B, 5, sdmmc3_dat2_pb5, sdmmc3, pwm1, displaya, spi3),
GMUX(0x3A4, B, 4, sdmmc3_dat3_pb4, sdmmc3, pwm0, displayb, spi3),
GMUX(0x3BC, DD, 1, pex_l0_rst_n_pdd1, pe0, rsvd2, rsvd3, rsvd4),
GMUX(0x3C0, DD, 2, pex_l0_clkreq_n_pdd2, pe0, rsvd2, rsvd3, rsvd4),
GMUX(0x3C4, DD, 3, pex_wake_n_pdd3, pe, rsvd2, rsvd3, rsvd4),
GMUX(0x3CC, DD, 5, pex_l1_rst_n_pdd5, pe1, rsvd2, rsvd3, rsvd4),
GMUX(0x3D0, DD, 6, pex_l1_clkreq_n_pdd6, pe1, rsvd2, rsvd3, rsvd4),
GMUX(0x3E0, EE, 3, hdmi_cec_pee3, cec, rsvd2, rsvd3, rsvd4),
GMUX(0x3E4, V, 3, sdmmc1_wp_n_pv3, sdmmc1, clk12, spi4, uarta),
GMUX(0x3E8, V, 2, sdmmc3_cd_n_pv2, sdmmc3, owr, rsvd3, rsvd4),
GMUX(0x3EC, W, 2, gpio_w2_aud_pw2, spi6, rsvd2, spi2, i2c1),
GMUX(0x3F0, W, 3, gpio_w3_aud_pw3, spi6, spi1, spi2, i2c1),
GMUX(0x3F4, N, 4, usb_vbus_en0_pn4, usb, rsvd2, rsvd3, rsvd4),
GMUX(0x3F8, N, 5, usb_vbus_en1_pn5, usb, rsvd2, rsvd3, rsvd4),
GMUX(0x3FC, EE, 5, sdmmc3_clk_lb_in_pee5, sdmmc3, rsvd2, rsvd3, rsvd4),
GMUX(0x400, EE, 4, sdmmc3_clk_lb_out_pee4, sdmmc3, rsvd2, rsvd3, rsvd4),
FMUX(0x404, gmi_clk_lb, sdmmc2, rsvd2, gmi, rsvd4),
FMUX(0x408, reset_out_n, rsvd1, rsvd2, rsvd3, reset_out_n),
GMUX(0x40C, T, 0, kb_row16_pt0, kbc, rsvd2, rsvd3, uartc),
GMUX(0x410, T, 1, kb_row17_pt1, kbc, rsvd2, rsvd3, uartc),
GMUX(0x414, FF, 1, usb_vbus_en2_pff1, usb, rsvd2, rsvd3, rsvd4),
GMUX(0x418, FF, 2, pff2, sata, rsvd2, rsvd3, rsvd4),
GMUX(0x430, FF, 0, dp_hpd_pff0, dp, rsvd2, rsvd3, rsvd4),
};
struct tegra_grp {
char *name;
bus_size_t reg;
int drvdn_shift;
int drvdn_mask;
int drvup_shift;
int drvup_mask;
};
#define GRP(r, nm, dn_s, dn_w, up_s, up_w) \
{ \
.name = #nm, \
.reg = r - 0x868, \
.drvdn_shift = dn_s, \
.drvdn_mask = (1 << dn_w) - 1, \
.drvup_shift = up_s, \
.drvup_mask = (1 << dn_w) - 1, \
}
/* Use register offsets from TRM */
static const struct tegra_grp pin_grp_tbl[] = {
GRP(0x868, ao1, 12, 5, 20, 5),
GRP(0x86C, ao2, 12, 5, 20, 5),
GRP(0x870, at1, 12, 7, 20, 7),
GRP(0x874, at2, 12, 7, 20, 7),
GRP(0x878, at3, 12, 7, 20, 7),
GRP(0x87C, at4, 12, 7, 20, 7),
GRP(0x880, at5, 14, 5, 19, 5),
GRP(0x884, cdev1, 12, 5, 20, 5),
GRP(0x888, cdev2, 12, 5, 20, 5),
GRP(0x890, dap1, 12, 5, 20, 5),
GRP(0x894, dap2, 12, 5, 20, 5),
GRP(0x898, dap3, 12, 5, 20, 5),
GRP(0x89C, dap4, 12, 5, 20, 5),
GRP(0x8A0, dbg, 12, 5, 20, 5),
GRP(0x8B0, sdio3, 12, 7, 20, 7),
GRP(0x8B4, spi, 12, 5, 20, 5),
GRP(0x8B8, uaa, 12, 5, 20, 5),
GRP(0x8BC, uab, 12, 5, 20, 5),
GRP(0x8C0, uart2, 12, 5, 20, 5),
GRP(0x8C4, uart3, 12, 5, 20, 5),
GRP(0x8EC, sdio1, 12, 7, 20, 7),
GRP(0x8FC, ddc, 12, 5, 20, 5),
GRP(0x900, gma, 14, 5, 20, 5),
GRP(0x910, gme, 14, 5, 19, 5),
GRP(0x914, gmf, 14, 5, 19, 5),
GRP(0x918, gmg, 14, 5, 19, 5),
GRP(0x91C, gmh, 14, 5, 19, 5),
GRP(0x920, owr, 12, 5, 20, 5),
GRP(0x924, uda, 12, 5, 20, 5),
GRP(0x928, gpv, 12, 5, 20, 5),
GRP(0x92C, dev3, 12, 5, 20, 5),
GRP(0x938, cec, 12, 5, 20, 5),
GRP(0x994, at6, 12, 7, 20, 7),
GRP(0x998, dap5, 12, 5, 20, 5),
GRP(0x99C, usb_vbus_en, 12, 5, 20, 5),
GRP(0x9A8, ao3, 12, 5, -1, 0),
GRP(0x9B0, ao0, 12, 5, 20, 5),
GRP(0x9B4, hv0, 12, 5, -1, 0),
GRP(0x9C4, sdio4, 12, 5, 20, 5),
GRP(0x9C8, ao4, 12, 7, 20, 7),
};
static const struct tegra_grp *
pinmux_search_grp(char *grp_name)
{
int i;
for (i = 0; i < nitems(pin_grp_tbl); i++) {
if (strcmp(grp_name, pin_grp_tbl[i].name) == 0)
return (&pin_grp_tbl[i]);
}
return (NULL);
}
static const struct tegra_mux *
pinmux_search_mux(char *pin_name)
{
int i;
for (i = 0; i < nitems(pin_mux_tbl); i++) {
if (strcmp(pin_name, pin_mux_tbl[i].name) == 0)
return (&pin_mux_tbl[i]);
}
return (NULL);
}
static int
pinmux_mux_function(const struct tegra_mux *mux, char *fnc_name)
{
int i;
for (i = 0; i < 4; i++) {
if (strcmp(fnc_name, mux->functions[i]) == 0)
return (i);
}
return (-1);
}
static int
pinmux_config_mux(struct pinmux_softc *sc, char *pin_name,
const struct tegra_mux *mux, struct pincfg *cfg)
{
int tmp;
uint32_t reg;
reg = bus_read_4(sc->mux_mem_res, mux->reg);
if (cfg->function != NULL) {
tmp = pinmux_mux_function(mux, cfg->function);
if (tmp == -1) {
device_printf(sc->dev,
"Unknown function %s for pin %s\n", cfg->function,
pin_name);
return (ENXIO);
}
reg &= ~(TEGRA_MUX_FUNCTION_MASK << TEGRA_MUX_FUNCTION_SHIFT);
reg |= (tmp & TEGRA_MUX_FUNCTION_MASK) <<
TEGRA_MUX_FUNCTION_SHIFT;
}
if (cfg->params[PROP_ID_PULL] != -1) {
reg &= ~(TEGRA_MUX_PUPD_MASK << TEGRA_MUX_PUPD_SHIFT);
reg |= (cfg->params[PROP_ID_PULL] & TEGRA_MUX_PUPD_MASK) <<
TEGRA_MUX_PUPD_SHIFT;
}
if (cfg->params[PROP_ID_TRISTATE] != -1) {
reg &= ~(1 << TEGRA_MUX_TRISTATE_SHIFT);
reg |= (cfg->params[PROP_ID_TRISTATE] & 1) <<
TEGRA_MUX_TRISTATE_SHIFT;
}
if (cfg->params[TEGRA_MUX_ENABLE_INPUT_SHIFT] != -1) {
reg &= ~(1 << TEGRA_MUX_ENABLE_INPUT_SHIFT);
reg |= (cfg->params[TEGRA_MUX_ENABLE_INPUT_SHIFT] & 1) <<
TEGRA_MUX_ENABLE_INPUT_SHIFT;
}
if (cfg->params[PROP_ID_ENABLE_INPUT] != -1) {
reg &= ~(1 << TEGRA_MUX_ENABLE_INPUT_SHIFT);
reg |= (cfg->params[PROP_ID_ENABLE_INPUT] & 1) <<
TEGRA_MUX_ENABLE_INPUT_SHIFT;
}
if (cfg->params[PROP_ID_ENABLE_INPUT] != -1) {
reg &= ~(1 << TEGRA_MUX_ENABLE_INPUT_SHIFT);
reg |= (cfg->params[PROP_ID_OPEN_DRAIN] & 1) <<
TEGRA_MUX_ENABLE_INPUT_SHIFT;
}
if (cfg->params[PROP_ID_LOCK] != -1) {
reg &= ~(1 << TEGRA_MUX_LOCK_SHIFT);
reg |= (cfg->params[PROP_ID_LOCK] & 1) <<
TEGRA_MUX_LOCK_SHIFT;
}
if (cfg->params[PROP_ID_IORESET] != -1) {
reg &= ~(1 << TEGRA_MUX_IORESET_SHIFT);
reg |= (cfg->params[PROP_ID_IORESET] & 1) <<
TEGRA_MUX_IORESET_SHIFT;
}
if (cfg->params[PROP_ID_RCV_SEL] != -1) {
reg &= ~(1 << TEGRA_MUX_RCV_SEL_SHIFT);
reg |= (cfg->params[PROP_ID_RCV_SEL] & 1) <<
TEGRA_MUX_RCV_SEL_SHIFT;
}
bus_write_4(sc->mux_mem_res, mux->reg, reg);
return (0);
}
static int
pinmux_config_grp(struct pinmux_softc *sc, char *grp_name,
const struct tegra_grp *grp, struct pincfg *cfg)
{
uint32_t reg;
reg = bus_read_4(sc->pad_mem_res, grp->reg);
if (cfg->params[PROP_ID_HIGH_SPEED_MODE] != -1) {
reg &= ~(1 << TEGRA_GRP_HSM_SHIFT);
reg |= (cfg->params[PROP_ID_HIGH_SPEED_MODE] & 1) <<
TEGRA_GRP_HSM_SHIFT;
}
if (cfg->params[PROP_ID_SCHMITT] != -1) {
reg &= ~(1 << TEGRA_GRP_SCHMT_SHIFT);
reg |= (cfg->params[PROP_ID_SCHMITT] & 1) <<
TEGRA_GRP_SCHMT_SHIFT;
}
if (cfg->params[PROP_ID_DRIVE_TYPE] != -1) {
reg &= ~(TEGRA_GRP_DRV_TYPE_MASK << TEGRA_GRP_DRV_TYPE_SHIFT);
reg |= (cfg->params[PROP_ID_DRIVE_TYPE] &
TEGRA_GRP_DRV_TYPE_MASK) << TEGRA_GRP_DRV_TYPE_SHIFT;
}
if (cfg->params[PROP_ID_SLEW_RATE_RISING] != -1) {
reg &= ~(TEGRA_GRP_DRV_DRVDN_SLWR_MASK <<
TEGRA_GRP_DRV_DRVDN_SLWR_SHIFT);
reg |= (cfg->params[PROP_ID_SLEW_RATE_RISING] &
TEGRA_GRP_DRV_DRVDN_SLWR_MASK) <<
TEGRA_GRP_DRV_DRVDN_SLWR_SHIFT;
}
if (cfg->params[PROP_ID_SLEW_RATE_FALLING] != -1) {
reg &= ~(TEGRA_GRP_DRV_DRVUP_SLWF_MASK <<
TEGRA_GRP_DRV_DRVUP_SLWF_SHIFT);
reg |= (cfg->params[PROP_ID_SLEW_RATE_FALLING] &
TEGRA_GRP_DRV_DRVUP_SLWF_MASK) <<
TEGRA_GRP_DRV_DRVUP_SLWF_SHIFT;
}
if ((cfg->params[PROP_ID_DRIVE_DOWN_STRENGTH] != -1) &&
(grp->drvdn_mask != -1)) {
reg &= ~(grp->drvdn_shift << grp->drvdn_mask);
reg |= (cfg->params[PROP_ID_DRIVE_DOWN_STRENGTH] &
grp->drvdn_mask) << grp->drvdn_shift;
}
if ((cfg->params[PROP_ID_DRIVE_UP_STRENGTH] != -1) &&
(grp->drvup_mask != -1)) {
reg &= ~(grp->drvup_shift << grp->drvup_mask);
reg |= (cfg->params[PROP_ID_DRIVE_UP_STRENGTH] &
grp->drvup_mask) << grp->drvup_shift;
}
bus_write_4(sc->pad_mem_res, grp->reg, reg);
return (0);
}
static int
pinmux_config_node(struct pinmux_softc *sc, char *pin_name, struct pincfg *cfg)
{
const struct tegra_mux *mux;
const struct tegra_grp *grp;
uint32_t reg;
int rv;
/* Handle MIPI special case first */
if (strcmp(pin_name, "dsi_b") == 0) {
if (cfg->function == NULL) {
/* nothing to set */
return (0);
}
reg = bus_read_4(sc->mipi_mem_res, 0); /* register 0x820 */
if (strcmp(cfg->function, "csi") == 0)
reg &= ~(1 << 1);
else if (strcmp(cfg->function, "dsi_b") == 0)
reg |= (1 << 1);
bus_write_4(sc->mipi_mem_res, 0, reg); /* register 0x820 */
}
/* Handle pin muxes */
mux = pinmux_search_mux(pin_name);
if (mux != NULL) {
if (mux->gpio_num != -1) {
/* XXXX TODO: Reserve gpio here */
}
rv = pinmux_config_mux(sc, pin_name, mux, cfg);
return (rv);
}
/* Handle pin groups */
grp = pinmux_search_grp(pin_name);
if (grp != NULL) {
rv = pinmux_config_grp(sc, pin_name, grp, cfg);
return (rv);
}
device_printf(sc->dev, "Unknown pin: %s\n", pin_name);
return (ENXIO);
}
static int
pinmux_read_node(struct pinmux_softc *sc, phandle_t node, struct pincfg *cfg,
char **pins, int *lpins)
{
int rv, i;
*lpins = OF_getprop_alloc(node, "nvidia,pins", (void **)pins);
if (*lpins <= 0)
return (ENOENT);
/* Read function (mux) settings. */
rv = OF_getprop_alloc(node, "nvidia,function",
(void **)&cfg->function);
if (rv <= 0)
cfg->function = NULL;
/* Read numeric properties. */
for (i = 0; i < PROP_ID_MAX_ID; i++) {
rv = OF_getencprop(node, prop_names[i].name, &cfg->params[i],
sizeof(cfg->params[i]));
if (rv <= 0)
cfg->params[i] = -1;
}
return (0);
}
static int
pinmux_process_node(struct pinmux_softc *sc, phandle_t node)
{
struct pincfg cfg;
char *pins, *pname;
int i, len, lpins, rv;
rv = pinmux_read_node(sc, node, &cfg, &pins, &lpins);
if (rv != 0)
return (rv);
len = 0;
pname = pins;
do {
i = strlen(pname) + 1;
rv = pinmux_config_node(sc, pname, &cfg);
if (rv != 0)
device_printf(sc->dev,
"Cannot configure pin: %s: %d\n", pname, rv);
len += i;
pname += i;
} while (len < lpins);
if (pins != NULL)
OF_prop_free(pins);
if (cfg.function != NULL)
OF_prop_free(cfg.function);
return (rv);
}
static int pinmux_configure(device_t dev, phandle_t cfgxref)
{
struct pinmux_softc *sc;
phandle_t node, cfgnode;
int rv;
sc = device_get_softc(dev);
cfgnode = OF_node_from_xref(cfgxref);
for (node = OF_child(cfgnode); node != 0; node = OF_peer(node)) {
if (!ofw_bus_node_status_okay(node))
continue;
rv = pinmux_process_node(sc, node);
}
return (0);
}
static int
pinmux_probe(device_t dev)
{
if (!ofw_bus_status_okay(dev))
return (ENXIO);
if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
return (ENXIO);
device_set_desc(dev, "Tegra pin configuration");
return (BUS_PROBE_DEFAULT);
}
static int
pinmux_detach(device_t dev)
{
/* This device is always present. */
return (EBUSY);
}
static int
pinmux_attach(device_t dev)
{
struct pinmux_softc * sc;
int rid;
sc = device_get_softc(dev);
sc->dev = dev;
rid = 0;
sc->pad_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
RF_ACTIVE);
if (sc->pad_mem_res == NULL) {
device_printf(dev, "Cannot allocate memory resources\n");
return (ENXIO);
}
rid = 1;
sc->mux_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
RF_ACTIVE);
if (sc->mux_mem_res == NULL) {
device_printf(dev, "Cannot allocate memory resources\n");
return (ENXIO);
}
rid = 2;
sc->mipi_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
RF_ACTIVE);
if (sc->mipi_mem_res == NULL) {
device_printf(dev, "Cannot allocate memory resources\n");
return (ENXIO);
}
/* Register as a pinctrl device and process default configuration */
fdt_pinctrl_register(dev, NULL);
fdt_pinctrl_configure_by_name(dev, "boot");
return (0);
}
static device_method_t tegra_pinmux_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pinmux_probe),
DEVMETHOD(device_attach, pinmux_attach),
DEVMETHOD(device_detach, pinmux_detach),
/* fdt_pinctrl interface */
DEVMETHOD(fdt_pinctrl_configure,pinmux_configure),
DEVMETHOD_END
};
static devclass_t tegra_pinmux_devclass;
static DEFINE_CLASS_0(pinmux, tegra_pinmux_driver, tegra_pinmux_methods,
sizeof(struct pinmux_softc));
EARLY_DRIVER_MODULE(tegra_pinmux, simplebus, tegra_pinmux_driver,
tegra_pinmux_devclass, NULL, NULL, 71);
| /*-
* Copyright (c) 2016 <NAME> <<EMAIL>>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* Pin multiplexer driver for Tegra SoCs.
*/
#include <IMPORT_18>
#include <IMPORT_19>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/malloc.h>
#include <sys/rman.h>
#include <machine/bus.h>
#include <machine/fdt.h>
#include <dev/fdt/fdt_common.h>
#include <dev/fdt/fdt_pinctrl.h>
#include <IMPORT_20>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
/* Pin multipexor register. */
#define TEGRA_MUX_FUNCTION_MASK 0x03
#define TEGRA_MUX_FUNCTION_SHIFT 0
#define TEGRA_MUX_PUPD_MASK 0x03
#define VAR_302 2
#define TEGRA_MUX_TRISTATE_SHIFT 4
#define TEGRA_MUX_ENABLE_INPUT_SHIFT 5
#define TEGRA_MUX_OPEN_DRAIN_SHIFT 6
#define TEGRA_MUX_LOCK_SHIFT 7
#define TEGRA_MUX_IORESET_SHIFT 8
#define VAR_303 9
/* Pin goup register. */
#define VAR_304 2
#define TEGRA_GRP_SCHMT_SHIFT 3
#define VAR_305 6
#define TEGRA_GRP_DRV_TYPE_MASK 0x03
#define TEGRA_GRP_DRV_DRVDN_SLWR_SHIFT 28
#define TEGRA_GRP_DRV_DRVDN_SLWR_MASK 0x03
#define TEGRA_GRP_DRV_DRVUP_SLWF_SHIFT 30
#define TEGRA_GRP_DRV_DRVUP_SLWF_MASK 0x03
struct pinmux_softc {
device_t dev;
struct resource *pad_mem_res;
struct resource *VAR_306;
struct resource *mipi_mem_res;
};
static struct ofw_compat_data VAR_307[] = {
{"nvidia,tegra124-pinmux", 1},
{NULL, 0},
};
enum prop_id {
PROP_ID_PULL,
PROP_ID_TRISTATE,
VAR_308,
PROP_ID_OPEN_DRAIN,
PROP_ID_LOCK,
VAR_309,
PROP_ID_RCV_SEL,
PROP_ID_HIGH_SPEED_MODE,
PROP_ID_SCHMITT,
VAR_310,
PROP_ID_DRIVE_DOWN_STRENGTH,
PROP_ID_DRIVE_UP_STRENGTH,
PROP_ID_SLEW_RATE_FALLING,
PROP_ID_SLEW_RATE_RISING,
PROP_ID_DRIVE_TYPE,
PROP_ID_MAX_ID
};
/* Numeric based parameters. */
static const struct CLASS_15 {
const char *name;
enum prop_id VAR_311;
} prop_names[] = {
{"nvidia,pull", PROP_ID_PULL},
{"nvidia,tristate", PROP_ID_TRISTATE},
{"nvidia,enable-input", VAR_308},
{"nvidia,open-drain", PROP_ID_OPEN_DRAIN},
{"nvidia,lock", PROP_ID_LOCK},
{"nvidia,io-reset", VAR_309},
{"nvidia,rcv-sel", PROP_ID_RCV_SEL},
{"nvidia,high-speed-mode", PROP_ID_HIGH_SPEED_MODE},
{"nvidia,schmitt", PROP_ID_SCHMITT},
{"nvidia,low-power-mode", VAR_310},
{"nvidia,pull-down-strength", PROP_ID_DRIVE_DOWN_STRENGTH},
{"nvidia,pull-up-strength", PROP_ID_DRIVE_UP_STRENGTH},
{"nvidia,slew-rate-falling", PROP_ID_SLEW_RATE_FALLING},
{"nvidia,slew-rate-rising", PROP_ID_SLEW_RATE_RISING},
{"nvidia,drive-type", PROP_ID_DRIVE_TYPE},
};
/*
* configuration for one pin group.
*/
struct pincfg {
char *function;
int params[PROP_ID_MAX_ID];
};
#define GPIO_BANK_A 0
#define VAR_312 1
#define GPIO_BANK_C 2
#define VAR_313 3
#define GPIO_BANK_E 4
#define GPIO_BANK_F 5
#define VAR_314 6
#define GPIO_BANK_H 7
#define GPIO_BANK_I 8
#define GPIO_BANK_J 9
#define GPIO_BANK_K 10
#define GPIO_BANK_L 11
#define GPIO_BANK_M 12
#define VAR_315 13
#define GPIO_BANK_O 14
#define GPIO_BANK_P 15
#define GPIO_BANK_Q 16
#define GPIO_BANK_R 17
#define GPIO_BANK_S 18
#define GPIO_BANK_T 19
#define GPIO_BANK_U 20
#define GPIO_BANK_V 21
#define VAR_316 22
#define GPIO_BANK_X 23
#define GPIO_BANK_Y 24
#define GPIO_BANK_Z 25
#define GPIO_BANK_AA 26
#define GPIO_BANK_BB 27
#define GPIO_BANK_CC 28
#define GPIO_BANK_DD 29
#define GPIO_BANK_EE 30
#define GPIO_BANK_FF 31
#define FUNC_1(b, p) (8 * (b) + (p))
struct tegra_mux {
char *name;
bus_size_t reg;
char *functions[4];
int gpio_num;
};
#define GMUX(r, gb, VAR_317, nm, f1, f2, f3, f4) \
{ \
.name = #nm, \
.reg = r, \
.gpio_num = GPIO_NUM(GPIO_BANK_##gb, gi), \
.functions = {#f1, #f2, #f3, #f4}, \
}
#define FMUX(r, nm, f1, f2, f3, f4) \
{ \
.name = #nm, \
.reg = r, \
.gpio_num = -1, \
.functions = {#f1, #f2, #f3, #f4}, \
}
static const struct tegra_mux pin_mux_tbl[] = {
GMUX(0x000, VAR_318, 1, ulpi_data0_po1, spi3, hsi, uarta, ulpi),
GMUX(0x004, VAR_318, 2, ulpi_data1_po2, spi3, hsi, uarta, ulpi),
GMUX(0x008, VAR_318, 3, ulpi_data2_po3, spi3, hsi, uarta, ulpi),
GMUX(0x00C, VAR_318, 4, ulpi_data3_po4, spi3, hsi, uarta, ulpi),
GMUX(0x010, VAR_318, 5, ulpi_data4_po5, spi2, hsi, uarta, ulpi),
GMUX(0x014, VAR_318, 6, ulpi_data5_po6, spi2, hsi, uarta, ulpi),
GMUX(0x018, VAR_318, 7, ulpi_data6_po7, spi2, hsi, uarta, ulpi),
GMUX(0x01C, VAR_318, 0, VAR_319, spi2, hsi, uarta, ulpi),
GMUX(0x020, P, 9, ulpi_clk_py0, spi1, spi5, uartd, ulpi),
GMUX(0x024, P, 1, ulpi_dir_py1, spi1, spi5, uartd, ulpi),
GMUX(0x028, P, 2, VAR_320, spi1, spi5, uartd, ulpi),
GMUX(0x02C, P, 3, ulpi_stp_py3, spi1, spi5, uartd, ulpi),
GMUX(0x030, P, 0, dap3_fs_pp0, i2s2, spi5, displaya, displayb),
GMUX(0x034, P, 1, dap3_din_pp1, i2s2, spi5, displaya, displayb),
GMUX(0x038, P, 2, dap3_dout_pp2, i2s2, spi5, displaya, rsvd4),
GMUX(0x03C, P, 3, dap3_sclk_pp3, i2s2, spi5, rsvd3, displayb),
GMUX(0x040, V, 0, pv0, rsvd1, VAR_321, rsvd3, rsvd4),
GMUX(0x044, V, 1, pv1, rsvd1, VAR_321, rsvd3, rsvd4),
GMUX(0x048, Z, 0, sdmmc1_clk_pz0, sdmmc1, clk12, rsvd3, rsvd4),
GMUX(0x04C, Z, 1, sdmmc1_cmd_pz1, sdmmc1, spdif, spi4, uarta),
GMUX(0x050, Y, 4, VAR_322, sdmmc1, spdif, spi4, uarta),
GMUX(0x054, Y, 5, sdmmc1_dat2_py5, sdmmc1, pwm0, spi4, uarta),
GMUX(0x058, Y, 6, sdmmc1_dat1_py6, sdmmc1, pwm1, spi4, uarta),
GMUX(0x05C, Y, 7, sdmmc1_dat0_py7, sdmmc1, VAR_321, spi4, uarta),
GMUX(0x068, W, 5, clk2_out_pw5, extperiph2, VAR_321, rsvd3, rsvd4),
GMUX(0x06C, CC, 5, clk2_req_pcc5, dap, VAR_321, rsvd3, rsvd4),
GMUX(0x110, N, 7, hdmi_int_pn7, rsvd1, VAR_321, rsvd3, rsvd4),
GMUX(0x114, V, 4, VAR_323, i2c4, VAR_321, rsvd3, rsvd4),
GMUX(0x118, V, 5, ddc_sda_pv5, i2c4, VAR_321, rsvd3, rsvd4),
GMUX(0x164, V, 3, uart2_rxd_pc3, VAR_324, spdif, uarta, spi4),
GMUX(0x168, C, 2, VAR_325, VAR_324, spdif, uarta, spi4),
GMUX(0x16C, J, 6, uart2_rts_n_pj6, uarta, uartb, gmi, spi4),
GMUX(0x170, J, 5, uart2_cts_n_pj5, uarta, uartb, gmi, spi4),
GMUX(0x174, W, 6, uart3_txd_pw6, uartc, VAR_321, gmi, spi4),
GMUX(0x178, W, 7, uart3_rxd_pw7, uartc, VAR_321, gmi, spi4),
GMUX(0x17C, S, 1, uart3_cts_n_pa1, uartc, sdmmc1, dtv, gmi),
GMUX(0x180, C, 0, uart3_rts_n_pc0, uartc, pwm0, dtv, gmi),
GMUX(0x184, U, 0, pu0, owr, uarta, gmi, rsvd4),
GMUX(0x188, U, 1, pu1, rsvd1, uarta, gmi, rsvd4),
GMUX(0x18C, U, 2, VAR_326, rsvd1, uarta, gmi, rsvd4),
GMUX(0x190, U, 3, VAR_327, pwm0, uarta, gmi, displayb),
GMUX(0x194, U, 4, VAR_328, pwm1, uarta, gmi, displayb),
GMUX(0x198, U, 5, pu5, pwm2, uarta, gmi, displayb),
GMUX(0x19C, U, 6, VAR_329, pwm3, uarta, rsvd3, gmi),
GMUX(0x1A0, C, 5, gen1_i2c_sda_pc5, i2c1, VAR_321, rsvd3, rsvd4),
GMUX(0x1A4, C, 4, gen1_i2c_scl_pc4, i2c1, VAR_321, rsvd3, rsvd4),
GMUX(0x1A8, P, 3, dap4_fs_pp4, i2s3, gmi, dtv, rsvd4),
GMUX(0x1AC, P, 4, dap4_din_pp5, i2s3, gmi, rsvd3, rsvd4),
GMUX(0x1B0, P, 5, dap4_dout_pp6, i2s3, gmi, dtv, rsvd4),
GMUX(0x1B4, P, 7, dap4_sclk_pp7, i2s3, gmi, rsvd3, rsvd4),
GMUX(0x1B8, P, 0, clk3_out_pee0, extperiph3, VAR_321, rsvd3, rsvd4),
GMUX(0x1BC, EE, 1, clk3_req_pee1, dev3, VAR_321, rsvd3, rsvd4),
GMUX(0x1C0, C, 7, VAR_330, rsvd1, VAR_321, gmi, gmi_alt),
GMUX(0x1C4, I, 5, pi5, VAR_331, VAR_321, gmi, rsvd4),
GMUX(0x1C8, I, 7, VAR_332, rsvd1, trace, gmi, dtv),
GMUX(0x1CC, K, 0, pk0, rsvd1, sdmmc3, gmi, soc),
GMUX(0x1D0, K, 1, pk1, VAR_331, trace, gmi, rsvd4),
GMUX(0x1D4, J, 0, pj0, rsvd1, VAR_321, gmi, usb),
GMUX(0x1D8, J, 2, pj2, rsvd1, VAR_321, gmi, soc),
GMUX(0x1DC, K, 3, pk3, VAR_331, trace, gmi, VAR_333),
GMUX(0x1E0, K, 4, VAR_334, VAR_331, VAR_321, gmi, gmi_alt),
GMUX(0x1E4, K, 2, pk2, rsvd1, VAR_321, gmi, rsvd4),
GMUX(0x1E8, I, 3, VAR_335, rsvd1, VAR_321, gmi, spi4),
GMUX(0x1EC, I, 6, pi6, rsvd1, VAR_321, gmi, VAR_331),
GMUX(0x1F0, G, 0, pg0, rsvd1, VAR_321, gmi, rsvd4),
GMUX(0x1F4, G, 1, pg1, rsvd1, VAR_321, gmi, rsvd4),
GMUX(0x1F8, G, 2, pg2, rsvd1, trace, gmi, rsvd4),
GMUX(0x1FC, G, 3, pg3, rsvd1, trace, gmi, rsvd4),
GMUX(0x200, G, 4, VAR_336, rsvd1, tmds, gmi, spi4),
GMUX(0x204, G, 5, pg5, rsvd1, VAR_321, gmi, spi4),
GMUX(0x208, G, 6, VAR_337, rsvd1, VAR_321, gmi, spi4),
GMUX(0x20C, G, 7, pg7, rsvd1, VAR_321, gmi, spi4),
GMUX(0x210, H, 0, ph0, pwm0, trace, gmi, dtv),
GMUX(0x214, H, 1, VAR_338, pwm1, tmds, gmi, displaya),
GMUX(0x218, H, 2, ph2, pwm2, tmds, gmi, cldvfs),
GMUX(0x21C, H, 3, ph3, pwm3, spi4, gmi, cldvfs),
GMUX(0x220, H, 4, VAR_339, VAR_331, VAR_321, gmi, rsvd4),
GMUX(0x224, H, 5, ph5, VAR_331, VAR_321, gmi, rsvd4),
GMUX(0x228, H, 6, ph6, VAR_331, trace, gmi, dtv),
GMUX(0x22C, H, 7, ph7, VAR_331, trace, gmi, dtv),
GMUX(0x230, J, 7, pj7, uartd, VAR_321, gmi, gmi_alt),
GMUX(0x234, VAR_340, 0, pb0, uartd, VAR_321, gmi, rsvd4),
GMUX(0x238, VAR_340, 1, VAR_341, uartd, VAR_321, gmi, rsvd4),
GMUX(0x23C, K, 7, VAR_342, uartd, VAR_321, gmi, rsvd4),
GMUX(0x240, I, 0, pi0, rsvd1, VAR_321, gmi, rsvd4),
GMUX(0x244, I, 1, pi1, rsvd1, VAR_321, gmi, rsvd4),
GMUX(0x248, I, 2, pi2, VAR_331, trace, gmi, rsvd4),
GMUX(0x24C, I, 4, pi4, spi4, trace, gmi, displaya),
GMUX(0x250, VAR_343, 5, gen2_i2c_scl_pt5, VAR_344, VAR_321, gmi, rsvd4),
GMUX(0x254, VAR_343, 6, gen2_i2c_sda_pt6, VAR_344, VAR_321, gmi, rsvd4),
GMUX(0x258, CC, 4, VAR_345, sdmmc4, VAR_321, gmi, rsvd4),
GMUX(0x25C, VAR_343, 7, VAR_346, sdmmc4, VAR_321, gmi, rsvd4),
GMUX(0x260, VAR_347, 0, sdmmc4_dat0_paa0, sdmmc4, spi3, gmi, rsvd4),
GMUX(0x264, VAR_347, 1, sdmmc4_dat1_paa1, sdmmc4, spi3, gmi, rsvd4),
GMUX(0x268, VAR_347, 2, sdmmc4_dat2_paa2, sdmmc4, spi3, gmi, rsvd4),
GMUX(0x26C, VAR_347, 3, sdmmc4_dat3_paa3, sdmmc4, spi3, gmi, rsvd4),
GMUX(0x270, VAR_347, 4, sdmmc4_dat4_paa4, sdmmc4, spi3, gmi, rsvd4),
GMUX(0x274, VAR_347, 5, sdmmc4_dat5_paa5, sdmmc4, spi3, rsvd3, rsvd4),
GMUX(0x278, VAR_347, 6, VAR_348, sdmmc4, spi3, gmi, rsvd4),
GMUX(0x27C, VAR_347, 7, VAR_349, sdmmc4, VAR_321, gmi, rsvd4),
GMUX(0x284, CC, 0, cam_mclk_pcc0, VAR_350, vi_alt1, vi_alt3, VAR_331),
GMUX(0x288, CC, 1, pcc1, i2s4, VAR_321, rsvd3, VAR_331),
GMUX(0x28C, BB, 0, pbb0, VAR_351, vimclk2, VAR_331, vimclk2_alt),
GMUX(0x290, BB, 1, cam_i2c_scl_pbb1, VAR_352, i2c3, rsvd3, VAR_331),
GMUX(0x294, BB, 2, VAR_353, VAR_354, i2c3, rsvd3, VAR_331),
GMUX(0x298, BB, 3, pbb3, vgp3, displaya, displayb, VAR_331),
GMUX(0x29C, BB, 4, pbb4, vgp4, displaya, displayb, VAR_331),
GMUX(0x2A0, BB, 5, pbb5, vgp5, displaya, rsvd3, VAR_331),
GMUX(0x2A4, BB, 6, pbb6, i2s4, VAR_321, displayb, VAR_331),
GMUX(0x2A8, BB, 7, pbb7, i2s4, VAR_321, rsvd3, VAR_331),
GMUX(0x2AC, CC, 2, pcc2, i2s4, VAR_321, sdmmc3, VAR_331),
FMUX(0x2B0, jtag_rtck, rtck, VAR_321, rsvd3, rsvd4),
GMUX(0x2B4, Z, 6, pwr_i2c_scl_pz6, i2cpwr, VAR_321, rsvd3, rsvd4),
GMUX(0x2B8, Z, 7, pwr_i2c_sda_pz7, i2cpwr, VAR_321, rsvd3, rsvd4),
GMUX(0x2BC, VAR_355, 0, kb_row0_pr0, kbc, VAR_321, rsvd3, rsvd4),
GMUX(0x2C0, VAR_355, 1, kb_row1_pr1, kbc, VAR_321, rsvd3, rsvd4),
GMUX(0x2C4, VAR_355, 2, kb_row2_pr2, kbc, VAR_321, rsvd3, rsvd4),
GMUX(0x2C8, VAR_355, 3, kb_row3_pr3, kbc, displaya, sys, displayb),
GMUX(0x2CC, VAR_355, 4, kb_row4_pr4, kbc, displaya, rsvd3, displayb),
GMUX(0x2D0, VAR_355, 5, kb_row5_pr5, kbc, displaya, rsvd3, displayb),
GMUX(0x2D4, VAR_355, 6, kb_row6_pr6, kbc, displaya, displaya_alt, displayb),
GMUX(0x2D8, VAR_355, 7, kb_row7_pr7, kbc, VAR_321, cldvfs, uarta),
GMUX(0x2DC, S, 0, VAR_356, kbc, VAR_321, cldvfs, uarta),
GMUX(0x2E0, S, 1, VAR_357, kbc, VAR_321, rsvd3, uarta),
GMUX(0x2E4, S, 2, VAR_358, kbc, VAR_321, rsvd3, uarta),
GMUX(0x2E8, S, 3, VAR_359, kbc, VAR_321, rsvd3, VAR_324),
GMUX(0x2EC, S, 4, kb_row12_ps4, kbc, VAR_321, rsvd3, VAR_324),
GMUX(0x2F0, S, 5, kb_row13_ps5, kbc, VAR_321, spi2, rsvd4),
GMUX(0x2F4, S, 6, kb_row14_ps6, kbc, VAR_321, spi2, rsvd4),
GMUX(0x2F8, S, 7, kb_row15_ps7, kbc, soc, rsvd3, rsvd4),
GMUX(0x2FC, Q, 0, kb_col0_pq0, kbc, VAR_321, spi2, rsvd4),
GMUX(0x300, Q, 1, kb_col1_pq1, kbc, VAR_321, spi2, rsvd4),
GMUX(0x304, Q, 2, kb_col2_pq2, kbc, VAR_321, spi2, rsvd4),
GMUX(0x308, Q, 3, kb_col3_pq3, kbc, displaya, pwm2, uarta),
GMUX(0x30C, Q, 4, kb_col4_pq4, kbc, owr, sdmmc3, uarta),
GMUX(0x310, Q, 5, kb_col5_pq5, kbc, VAR_321, sdmmc3, rsvd4),
GMUX(0x314, Q, 6, VAR_360, kbc, VAR_321, spi2, uartd),
GMUX(0x318, Q, 7, kb_col7_pq7, kbc, VAR_321, spi2, uartd),
GMUX(0x31C, VAR_361, 0, clk_32k_out_pa0, VAR_362, soc, rsvd3, rsvd4),
FMUX(0x324, core_pwr_req, pwron, VAR_321, rsvd3, rsvd4),
FMUX(0x328, cpu_pwr_req, VAR_363, VAR_321, rsvd3, rsvd4),
FMUX(0x32C, VAR_364, pmi, VAR_321, rsvd3, rsvd4),
FMUX(0x330, clk_32k_in, clk, VAR_321, rsvd3, rsvd4),
FMUX(0x334, owr, owr, VAR_321, rsvd3, rsvd4),
GMUX(0x338, N, 0, dap1_fs_pn0, i2s0, hda, gmi, rsvd4),
GMUX(0x33C, N, 1, VAR_365, i2s0, hda, gmi, rsvd4),
GMUX(0x340, N, 2, dap1_dout_pn2, i2s0, hda, gmi, VAR_366),
GMUX(0x344, N, 3, dap1_sclk_pn3, i2s0, hda, gmi, rsvd4),
GMUX(0x348, EE, 2, dap_mclk1_req_pee2, dap, dap1, VAR_366, rsvd4),
GMUX(0x34C, W, 4, dap_mclk1_pw4, extperiph1, dap2, rsvd3, rsvd4),
GMUX(0x350, K, 6, spdif_in_pk6, spdif, VAR_321, rsvd3, i2c3),
GMUX(0x354, K, 5, spdif_out_pk5, spdif, VAR_321, rsvd3, i2c3),
GMUX(0x358, VAR_361, 2, dap2_fs_pa2, VAR_367, hda, gmi, rsvd4),
GMUX(0x35C, VAR_361, 4, dap2_din_pa4, VAR_367, hda, gmi, rsvd4),
GMUX(0x360, VAR_361, 5, dap2_dout_pa5, VAR_367, hda, gmi, rsvd4),
GMUX(0x364, VAR_361, 3, dap2_sclk_pa3, VAR_367, hda, gmi, rsvd4),
GMUX(0x368, X, 0, dvfs_pwm_px0, VAR_368, cldvfs, gmi, rsvd4),
GMUX(0x36C, X, 1, gpio_x1_aud_px1, VAR_368, VAR_321, gmi, rsvd4),
GMUX(0x370, X, 3, gpio_x3_aud_px3, VAR_368, spi1, gmi, rsvd4),
GMUX(0x374, X, 2, dvfs_clk_px2, VAR_368, cldvfs, gmi, rsvd4),
GMUX(0x378, X, 4, gpio_x4_aud_px4, gmi, spi1, spi2, dap2),
GMUX(0x37C, X, 5, gpio_x5_aud_px5, gmi, spi1, spi2, rsvd4),
GMUX(0x380, X, 6, gpio_x6_aud_px6, VAR_368, spi1, spi2, gmi),
GMUX(0x384, X, 7, gpio_x7_aud_px7, rsvd1, spi1, spi2, rsvd4),
GMUX(0x390, VAR_361, 6, sdmmc3_clk_pa6, sdmmc3, VAR_321, rsvd3, spi3),
GMUX(0x394, VAR_361, 7, VAR_369, sdmmc3, pwm3, uarta, spi3),
GMUX(0x398, VAR_340, 7, VAR_370, sdmmc3, VAR_321, rsvd3, spi3),
GMUX(0x39C, VAR_340, 6, VAR_371, sdmmc3, pwm2, uarta, spi3),
GMUX(0x3A0, VAR_340, 5, sdmmc3_dat2_pb5, sdmmc3, pwm1, displaya, spi3),
GMUX(0x3A4, VAR_340, 4, sdmmc3_dat3_pb4, sdmmc3, pwm0, displayb, spi3),
GMUX(0x3BC, DD, 1, pex_l0_rst_n_pdd1, pe0, VAR_321, rsvd3, rsvd4),
GMUX(0x3C0, DD, 2, pex_l0_clkreq_n_pdd2, pe0, VAR_321, rsvd3, rsvd4),
GMUX(0x3C4, DD, 3, pex_wake_n_pdd3, pe, VAR_321, rsvd3, rsvd4),
GMUX(0x3CC, DD, 5, VAR_372, pe1, VAR_321, rsvd3, rsvd4),
GMUX(0x3D0, DD, 6, pex_l1_clkreq_n_pdd6, pe1, VAR_321, rsvd3, rsvd4),
GMUX(0x3E0, EE, 3, hdmi_cec_pee3, cec, VAR_321, rsvd3, rsvd4),
GMUX(0x3E4, V, 3, sdmmc1_wp_n_pv3, sdmmc1, clk12, spi4, uarta),
GMUX(0x3E8, V, 2, sdmmc3_cd_n_pv2, sdmmc3, owr, rsvd3, rsvd4),
GMUX(0x3EC, W, 2, gpio_w2_aud_pw2, VAR_368, VAR_321, spi2, i2c1),
GMUX(0x3F0, W, 3, gpio_w3_aud_pw3, VAR_368, spi1, spi2, i2c1),
GMUX(0x3F4, N, 4, usb_vbus_en0_pn4, usb, VAR_321, rsvd3, rsvd4),
GMUX(0x3F8, N, 5, usb_vbus_en1_pn5, usb, VAR_321, rsvd3, rsvd4),
GMUX(0x3FC, EE, 5, sdmmc3_clk_lb_in_pee5, sdmmc3, VAR_321, rsvd3, rsvd4),
GMUX(0x400, EE, 4, sdmmc3_clk_lb_out_pee4, sdmmc3, VAR_321, rsvd3, rsvd4),
FMUX(0x404, gmi_clk_lb, VAR_331, VAR_321, gmi, rsvd4),
FMUX(0x408, reset_out_n, rsvd1, VAR_321, rsvd3, reset_out_n),
GMUX(0x40C, VAR_343, 0, kb_row16_pt0, kbc, VAR_321, rsvd3, uartc),
GMUX(0x410, VAR_343, 1, VAR_373, kbc, VAR_321, rsvd3, uartc),
GMUX(0x414, FF, 1, usb_vbus_en2_pff1, usb, VAR_321, rsvd3, rsvd4),
GMUX(0x418, FF, 2, pff2, VAR_366, VAR_321, rsvd3, rsvd4),
GMUX(0x430, FF, 0, VAR_374, dp, VAR_321, rsvd3, rsvd4),
};
struct CLASS_16 {
char *name;
bus_size_t reg;
int VAR_375;
int VAR_376;
int drvup_shift;
int drvup_mask;
};
#define GRP(r, nm, dn_s, VAR_377, up_s, VAR_378) \
{ \
.name = #nm, \
.reg = r - 0x868, \
.drvdn_shift = dn_s, \
.drvdn_mask = (1 << dn_w) - 1, \
.drvup_shift = up_s, \
.drvup_mask = (1 << dn_w) - 1, \
}
/* Use register offsets from TRM */
static const struct CLASS_16 pin_grp_tbl[] = {
GRP(0x868, ao1, 12, 5, 20, 5),
GRP(0x86C, VAR_379, 12, 5, 20, 5),
GRP(0x870, at1, 12, 7, 20, 7),
GRP(0x874, at2, 12, 7, 20, 7),
GRP(0x878, at3, 12, 7, 20, 7),
GRP(0x87C, VAR_380, 12, 7, 20, 7),
GRP(0x880, at5, 14, 5, 19, 5),
GRP(0x884, cdev1, 12, 5, 20, 5),
GRP(0x888, VAR_381, 12, 5, 20, 5),
GRP(0x890, dap1, 12, 5, 20, 5),
GRP(0x894, dap2, 12, 5, 20, 5),
GRP(0x898, dap3, 12, 5, 20, 5),
GRP(0x89C, dap4, 12, 5, 20, 5),
GRP(0x8A0, VAR_382, 12, 5, 20, 5),
GRP(0x8B0, VAR_383, 12, 7, 20, 7),
GRP(0x8B4, spi, 12, 5, 20, 5),
GRP(0x8B8, uaa, 12, 5, 20, 5),
GRP(0x8BC, uab, 12, 5, 20, 5),
GRP(0x8C0, uart2, 12, 5, 20, 5),
GRP(0x8C4, VAR_384, 12, 5, 20, 5),
GRP(0x8EC, sdio1, 12, 7, 20, 7),
GRP(0x8FC, VAR_385, 12, 5, 20, 5),
GRP(0x900, gma, 14, 5, 20, 5),
GRP(0x910, VAR_386, 14, 5, 19, 5),
GRP(0x914, gmf, 14, 5, 19, 5),
GRP(0x918, VAR_387, 14, 5, 19, 5),
GRP(0x91C, VAR_388, 14, 5, 19, 5),
GRP(0x920, owr, 12, 5, 20, 5),
GRP(0x924, VAR_389, 12, 5, 20, 5),
GRP(0x928, VAR_390, 12, 5, 20, 5),
GRP(0x92C, dev3, 12, 5, 20, 5),
GRP(0x938, cec, 12, 5, 20, 5),
GRP(0x994, at6, 12, 7, 20, 7),
GRP(0x998, dap5, 12, 5, 20, 5),
GRP(0x99C, VAR_391, 12, 5, 20, 5),
GRP(0x9A8, ao3, 12, 5, -1, 0),
GRP(0x9B0, ao0, 12, 5, 20, 5),
GRP(0x9B4, hv0, 12, 5, -1, 0),
GRP(0x9C4, sdio4, 12, 5, 20, 5),
GRP(0x9C8, ao4, 12, 7, 20, 7),
};
static const struct CLASS_16 *
pinmux_search_grp(char *grp_name)
{
int i;
for (i = 0; i < nitems(pin_grp_tbl); i++) {
if (strcmp(grp_name, pin_grp_tbl[i].name) == 0)
return (&pin_grp_tbl[i]);
}
return (NULL);
}
static const struct tegra_mux *
pinmux_search_mux(char *pin_name)
{
int i;
for (i = 0; i < nitems(pin_mux_tbl); i++) {
if (strcmp(pin_name, pin_mux_tbl[i].name) == 0)
return (&pin_mux_tbl[i]);
}
return (NULL);
}
static int
FUNC_4(const struct tegra_mux *mux, char *fnc_name)
{
int i;
for (i = 0; i < 4; i++) {
if (strcmp(fnc_name, mux->functions[i]) == 0)
return (i);
}
return (-1);
}
static int
pinmux_config_mux(struct pinmux_softc *sc, char *pin_name,
const struct tegra_mux *mux, struct pincfg *cfg)
{
int VAR_392;
uint32_t reg;
reg = FUNC_5(sc->VAR_306, mux->reg);
if (cfg->function != NULL) {
VAR_392 = FUNC_4(mux, cfg->function);
if (VAR_392 == -1) {
FUNC_6(sc->dev,
"Unknown function %s for pin %s\n", cfg->function,
pin_name);
return (ENXIO);
}
reg &= ~(TEGRA_MUX_FUNCTION_MASK << TEGRA_MUX_FUNCTION_SHIFT);
reg |= (VAR_392 & TEGRA_MUX_FUNCTION_MASK) <<
TEGRA_MUX_FUNCTION_SHIFT;
}
if (cfg->params[PROP_ID_PULL] != -1) {
reg &= ~(TEGRA_MUX_PUPD_MASK << VAR_302);
reg |= (cfg->params[PROP_ID_PULL] & TEGRA_MUX_PUPD_MASK) <<
VAR_302;
}
if (cfg->params[PROP_ID_TRISTATE] != -1) {
reg &= ~(1 << TEGRA_MUX_TRISTATE_SHIFT);
reg |= (cfg->params[PROP_ID_TRISTATE] & 1) <<
TEGRA_MUX_TRISTATE_SHIFT;
}
if (cfg->params[TEGRA_MUX_ENABLE_INPUT_SHIFT] != -1) {
reg &= ~(1 << TEGRA_MUX_ENABLE_INPUT_SHIFT);
reg |= (cfg->params[TEGRA_MUX_ENABLE_INPUT_SHIFT] & 1) <<
TEGRA_MUX_ENABLE_INPUT_SHIFT;
}
if (cfg->params[VAR_308] != -1) {
reg &= ~(1 << TEGRA_MUX_ENABLE_INPUT_SHIFT);
reg |= (cfg->params[VAR_308] & 1) <<
TEGRA_MUX_ENABLE_INPUT_SHIFT;
}
if (cfg->params[VAR_308] != -1) {
reg &= ~(1 << TEGRA_MUX_ENABLE_INPUT_SHIFT);
reg |= (cfg->params[PROP_ID_OPEN_DRAIN] & 1) <<
TEGRA_MUX_ENABLE_INPUT_SHIFT;
}
if (cfg->params[PROP_ID_LOCK] != -1) {
reg &= ~(1 << TEGRA_MUX_LOCK_SHIFT);
reg |= (cfg->params[PROP_ID_LOCK] & 1) <<
TEGRA_MUX_LOCK_SHIFT;
}
if (cfg->params[VAR_309] != -1) {
reg &= ~(1 << TEGRA_MUX_IORESET_SHIFT);
reg |= (cfg->params[VAR_309] & 1) <<
TEGRA_MUX_IORESET_SHIFT;
}
if (cfg->params[PROP_ID_RCV_SEL] != -1) {
reg &= ~(1 << VAR_303);
reg |= (cfg->params[PROP_ID_RCV_SEL] & 1) <<
VAR_303;
}
bus_write_4(sc->VAR_306, mux->reg, reg);
return (0);
}
static int
pinmux_config_grp(struct pinmux_softc *sc, char *grp_name,
const struct CLASS_16 *grp, struct pincfg *cfg)
{
uint32_t reg;
reg = FUNC_5(sc->pad_mem_res, grp->reg);
if (cfg->params[PROP_ID_HIGH_SPEED_MODE] != -1) {
reg &= ~(1 << VAR_304);
reg |= (cfg->params[PROP_ID_HIGH_SPEED_MODE] & 1) <<
VAR_304;
}
if (cfg->params[PROP_ID_SCHMITT] != -1) {
reg &= ~(1 << TEGRA_GRP_SCHMT_SHIFT);
reg |= (cfg->params[PROP_ID_SCHMITT] & 1) <<
TEGRA_GRP_SCHMT_SHIFT;
}
if (cfg->params[PROP_ID_DRIVE_TYPE] != -1) {
reg &= ~(TEGRA_GRP_DRV_TYPE_MASK << VAR_305);
reg |= (cfg->params[PROP_ID_DRIVE_TYPE] &
TEGRA_GRP_DRV_TYPE_MASK) << VAR_305;
}
if (cfg->params[PROP_ID_SLEW_RATE_RISING] != -1) {
reg &= ~(TEGRA_GRP_DRV_DRVDN_SLWR_MASK <<
TEGRA_GRP_DRV_DRVDN_SLWR_SHIFT);
reg |= (cfg->params[PROP_ID_SLEW_RATE_RISING] &
TEGRA_GRP_DRV_DRVDN_SLWR_MASK) <<
TEGRA_GRP_DRV_DRVDN_SLWR_SHIFT;
}
if (cfg->params[PROP_ID_SLEW_RATE_FALLING] != -1) {
reg &= ~(TEGRA_GRP_DRV_DRVUP_SLWF_MASK <<
TEGRA_GRP_DRV_DRVUP_SLWF_SHIFT);
reg |= (cfg->params[PROP_ID_SLEW_RATE_FALLING] &
TEGRA_GRP_DRV_DRVUP_SLWF_MASK) <<
TEGRA_GRP_DRV_DRVUP_SLWF_SHIFT;
}
if ((cfg->params[PROP_ID_DRIVE_DOWN_STRENGTH] != -1) &&
(grp->VAR_376 != -1)) {
reg &= ~(grp->VAR_375 << grp->VAR_376);
reg |= (cfg->params[PROP_ID_DRIVE_DOWN_STRENGTH] &
grp->VAR_376) << grp->VAR_375;
}
if ((cfg->params[PROP_ID_DRIVE_UP_STRENGTH] != -1) &&
(grp->drvup_mask != -1)) {
reg &= ~(grp->drvup_shift << grp->drvup_mask);
reg |= (cfg->params[PROP_ID_DRIVE_UP_STRENGTH] &
grp->drvup_mask) << grp->drvup_shift;
}
bus_write_4(sc->pad_mem_res, grp->reg, reg);
return (0);
}
static int
FUNC_7(struct pinmux_softc *sc, char *pin_name, struct pincfg *cfg)
{
const struct tegra_mux *mux;
const struct CLASS_16 *grp;
uint32_t reg;
int VAR_393;
/* Handle MIPI special case first */
if (strcmp(pin_name, "dsi_b") == 0) {
if (cfg->function == NULL) {
/* nothing to set */
return (0);
}
reg = FUNC_5(sc->mipi_mem_res, 0); /* register 0x820 */
if (strcmp(cfg->function, "csi") == 0)
reg &= ~(1 << 1);
else if (strcmp(cfg->function, "dsi_b") == 0)
reg |= (1 << 1);
bus_write_4(sc->mipi_mem_res, 0, reg); /* register 0x820 */
}
/* Handle pin muxes */
mux = pinmux_search_mux(pin_name);
if (mux != NULL) {
if (mux->gpio_num != -1) {
/* XXXX TODO: Reserve gpio here */
}
VAR_393 = pinmux_config_mux(sc, pin_name, mux, cfg);
return (VAR_393);
}
/* Handle pin groups */
grp = pinmux_search_grp(pin_name);
if (grp != NULL) {
VAR_393 = pinmux_config_grp(sc, pin_name, grp, cfg);
return (VAR_393);
}
FUNC_6(sc->dev, "Unknown pin: %s\n", pin_name);
return (ENXIO);
}
static int
pinmux_read_node(struct pinmux_softc *sc, phandle_t node, struct pincfg *cfg,
char **pins, int *VAR_394)
{
int VAR_393, i;
*VAR_394 = OF_getprop_alloc(node, "nvidia,pins", (void **)pins);
if (*VAR_394 <= 0)
return (ENOENT);
/* Read function (mux) settings. */
VAR_393 = OF_getprop_alloc(node, "nvidia,function",
(void **)&cfg->function);
if (VAR_393 <= 0)
cfg->function = NULL;
/* Read numeric properties. */
for (i = 0; i < PROP_ID_MAX_ID; i++) {
VAR_393 = OF_getencprop(node, prop_names[i].name, &cfg->params[i],
sizeof(cfg->params[i]));
if (VAR_393 <= 0)
cfg->params[i] = -1;
}
return (0);
}
static int
pinmux_process_node(struct pinmux_softc *sc, phandle_t node)
{
struct pincfg cfg;
char *pins, *pname;
int i, len, VAR_394, VAR_393;
VAR_393 = pinmux_read_node(sc, node, &cfg, &pins, &VAR_394);
if (VAR_393 != 0)
return (VAR_393);
len = 0;
pname = pins;
do {
i = strlen(pname) + 1;
VAR_393 = FUNC_7(sc, pname, &cfg);
if (VAR_393 != 0)
FUNC_6(sc->dev,
"Cannot configure pin: %s: %d\n", pname, VAR_393);
len += i;
pname += i;
} while (len < VAR_394);
if (pins != NULL)
FUNC_8(pins);
if (cfg.function != NULL)
FUNC_8(cfg.function);
return (VAR_393);
}
static int pinmux_configure(device_t dev, phandle_t cfgxref)
{
struct pinmux_softc *sc;
phandle_t node, cfgnode;
int VAR_393;
sc = FUNC_9(dev);
cfgnode = OF_node_from_xref(cfgxref);
for (node = OF_child(cfgnode); node != 0; node = OF_peer(node)) {
if (!ofw_bus_node_status_okay(node))
continue;
VAR_393 = pinmux_process_node(sc, node);
}
return (0);
}
static int
pinmux_probe(device_t dev)
{
if (!ofw_bus_status_okay(dev))
return (ENXIO);
if (!ofw_bus_search_compatible(dev, VAR_307)->ocd_data)
return (ENXIO);
device_set_desc(dev, "Tegra pin configuration");
return (BUS_PROBE_DEFAULT);
}
static int
pinmux_detach(device_t dev)
{
/* This device is always present. */
return (EBUSY);
}
static int
pinmux_attach(device_t dev)
{
struct pinmux_softc * sc;
int rid;
sc = FUNC_9(dev);
sc->dev = dev;
rid = 0;
sc->pad_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
VAR_395);
if (sc->pad_mem_res == NULL) {
FUNC_6(dev, "Cannot allocate memory resources\n");
return (ENXIO);
}
rid = 1;
sc->VAR_306 = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
VAR_395);
if (sc->VAR_306 == NULL) {
FUNC_6(dev, "Cannot allocate memory resources\n");
return (ENXIO);
}
rid = 2;
sc->mipi_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
VAR_395);
if (sc->mipi_mem_res == NULL) {
FUNC_6(dev, "Cannot allocate memory resources\n");
return (ENXIO);
}
/* Register as a pinctrl device and process default configuration */
fdt_pinctrl_register(dev, NULL);
fdt_pinctrl_configure_by_name(dev, "boot");
return (0);
}
static CLASS_17 tegra_pinmux_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pinmux_probe),
DEVMETHOD(device_attach, pinmux_attach),
DEVMETHOD(device_detach, pinmux_detach),
/* fdt_pinctrl interface */
DEVMETHOD(fdt_pinctrl_configure,pinmux_configure),
VAR_396
};
static devclass_t tegra_pinmux_devclass;
static DEFINE_CLASS_0(ID_0, tegra_pinmux_driver, tegra_pinmux_methods,
sizeof(struct pinmux_softc));
EARLY_DRIVER_MODULE(tegra_pinmux, simplebus, tegra_pinmux_driver,
tegra_pinmux_devclass, NULL, NULL, 71);
| 0.884709 | {'IMPORT_18': 'sys/param.h', 'IMPORT_19': 'sys/systm.h', 'IMPORT_20': 'dev/ofw/openfirm.h', 'VAR_302': 'TEGRA_MUX_PUPD_SHIFT', 'VAR_303': 'TEGRA_MUX_RCV_SEL_SHIFT', 'VAR_304': 'TEGRA_GRP_HSM_SHIFT', 'VAR_305': 'TEGRA_GRP_DRV_TYPE_SHIFT', 'VAR_306': 'mux_mem_res', 'VAR_307': 'compat_data', 'VAR_308': 'PROP_ID_ENABLE_INPUT', 'VAR_309': 'PROP_ID_IORESET', 'VAR_310': 'PROP_ID_LOW_POWER_MODE', 'CLASS_15': 'prop_name', 'VAR_311': 'id', 'VAR_312': 'GPIO_BANK_B', 'VAR_313': 'GPIO_BANK_D', 'VAR_314': 'GPIO_BANK_G', 'VAR_315': 'GPIO_BANK_N', 'VAR_316': 'GPIO_BANK_W', 'FUNC_1': 'GPIO_NUM', 'VAR_317': 'gi', 'VAR_318': 'O', 'VAR_319': 'ulpi_data7_po0', 'VAR_320': 'ulpi_nxt_py2', 'VAR_321': 'rsvd2', 'VAR_322': 'sdmmc1_dat3_py4', 'VAR_323': 'ddc_scl_pv4', 'VAR_324': 'irda', 'VAR_325': 'uart2_txd_pc2', 'VAR_326': 'pu2', 'VAR_327': 'pu3', 'VAR_328': 'pu4', 'VAR_329': 'pu6', 'VAR_330': 'pc7', 'VAR_331': 'sdmmc2', 'VAR_332': 'pi7', 'VAR_333': 'ccla', 'VAR_334': 'pk4', 'VAR_335': 'pi3', 'VAR_336': 'pg4', 'VAR_337': 'pg6', 'VAR_338': 'ph1', 'VAR_339': 'ph4', 'VAR_340': 'B', 'VAR_341': 'pb1', 'VAR_342': 'pk7', 'VAR_343': 'T', 'VAR_344': 'i2c2', 'VAR_345': 'sdmmc4_clk_pcc4', 'VAR_346': 'sdmmc4_cmd_pt7', 'VAR_347': 'AA', 'VAR_348': 'sdmmc4_dat6_paa6', 'VAR_349': 'sdmmc4_dat7_paa7', 'VAR_350': 'vi', 'VAR_351': 'vgp6', 'VAR_352': 'vgp1', 'VAR_353': 'cam_i2c_sda_pbb2', 'VAR_354': 'vgp2', 'VAR_355': 'R', 'VAR_356': 'kb_row8_ps0', 'VAR_357': 'kb_row9_ps1', 'VAR_358': 'kb_row10_ps2', 'VAR_359': 'kb_row11_ps3', 'VAR_360': 'kb_col6_pq6', 'VAR_361': 'A', 'VAR_362': 'blink', 'VAR_363': 'cpu', 'VAR_364': 'pwr_int_n', 'VAR_365': 'dap1_din_pn1', 'VAR_366': 'sata', 'VAR_367': 'i2s1', 'VAR_368': 'spi6', 'VAR_369': 'sdmmc3_cmd_pa7', 'VAR_370': 'sdmmc3_dat0_pb7', 'VAR_371': 'sdmmc3_dat1_pb6', 'VAR_372': 'pex_l1_rst_n_pdd5', 'VAR_373': 'kb_row17_pt1', 'VAR_374': 'dp_hpd_pff0', 'CLASS_16': 'tegra_grp', 'VAR_375': 'drvdn_shift', 'VAR_376': 'drvdn_mask', 'VAR_377': 'dn_w', 'VAR_378': 'up_w', 'VAR_379': 'ao2', 'VAR_380': 'at4', 'VAR_381': 'cdev2', 'VAR_382': 'dbg', 'VAR_383': 'sdio3', 'VAR_384': 'uart3', 'VAR_385': 'ddc', 'VAR_386': 'gme', 'VAR_387': 'gmg', 'VAR_388': 'gmh', 'VAR_389': 'uda', 'VAR_390': 'gpv', 'VAR_391': 'usb_vbus_en', 'FUNC_4': 'pinmux_mux_function', 'VAR_392': 'tmp', 'FUNC_5': 'bus_read_4', 'FUNC_6': 'device_printf', 'FUNC_7': 'pinmux_config_node', 'VAR_393': 'rv', 'VAR_394': 'lpins', 'FUNC_8': 'OF_prop_free', 'FUNC_9': 'device_get_softc', 'VAR_395': 'RF_ACTIVE', 'CLASS_17': 'device_method_t', 'VAR_396': 'DEVMETHOD_END', 'ID_0': 'pinmux'} |
/* track-item.h
*
* Copyright 2021 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <glib-2.0/glib-object.h>
#include <gtk-4.0/gtk/gtk.h>
#include "indexer/structs.h"
G_BEGIN_DECLS
#define KOTO_TYPE_TRACK_ITEM (koto_track_item_get_type())
G_DECLARE_FINAL_TYPE(KotoTrackItem, koto_track_item, KOTO, TRACK_ITEM, GtkBox)
KotoTrackItem* koto_track_item_new(KotoTrack * track);
void koto_track_item_handle_add_to_playlist_button_click(
GtkGestureClick * gesture,
int n_press,
double x,
double y,
gpointer user_data
);
KotoTrack * koto_track_item_get_track(KotoTrackItem * self);
void koto_track_item_set_track(
KotoTrackItem * self,
KotoTrack * track
);
G_END_DECLS
| /* track-item.h
*
* Copyright 2021 <NAME>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <IMPORT_0>
#include <IMPORT_1>
#include "IMPORT_2"
G_BEGIN_DECLS
#define KOTO_TYPE_TRACK_ITEM (koto_track_item_get_type())
FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4)
CLASS_0* FUNC_1(CLASS_1 * VAR_5);
void koto_track_item_handle_add_to_playlist_button_click(
CLASS_2 * gesture,
int VAR_6,
double VAR_7,
double VAR_8,
CLASS_3 VAR_9
);
CLASS_1 * FUNC_2(CLASS_0 * VAR_10);
void FUNC_3(
CLASS_0 * VAR_10,
CLASS_1 * VAR_5
);
G_END_DECLS
| 0.596352 | {'IMPORT_0': 'glib-2.0/glib-object.h', 'IMPORT_1': 'gtk-4.0/gtk/gtk.h', 'IMPORT_2': 'indexer/structs.h', 'FUNC_0': 'G_DECLARE_FINAL_TYPE', 'VAR_0': 'KotoTrackItem', 'CLASS_0': 'KotoTrackItem', 'VAR_1': 'koto_track_item', 'VAR_2': 'KOTO', 'VAR_3': 'TRACK_ITEM', 'VAR_4': 'GtkBox', 'FUNC_1': 'koto_track_item_new', 'CLASS_1': 'KotoTrack', 'VAR_5': 'track', 'CLASS_2': 'GtkGestureClick', 'VAR_6': 'n_press', 'VAR_7': 'x', 'VAR_8': 'y', 'CLASS_3': 'gpointer', 'VAR_9': 'user_data', 'FUNC_2': 'koto_track_item_get_track', 'VAR_10': 'self', 'FUNC_3': 'koto_track_item_set_track'} |