text
stringlengths
4
6.14k
/* =========================================================================== * The MIT License (MIT) * * Copyright (c) 2016 Jedidiah Buck McCready <jbuckmccready@gmail.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * ===========================================================================*/ #ifndef INTEGRATORMODEL_H #define INTEGRATORMODEL_H #include "Models/pendulumsystemmodel.h" #include <QObject> class QJsonObject; namespace staticpendulum { /// QML type to manage integrating pendulum system. class IntegratorModel : public QObject { Q_OBJECT Q_PROPERTY(double startingStepSize READ startingStepSize WRITE setStartingStepSize NOTIFY startingStepSizeChanged) Q_PROPERTY(double maximumStepSize READ maximumStepSize WRITE setMaximumStepSize NOTIFY maximumStepSizeChanged) Q_PROPERTY(double relativeTolerance READ relativeTolerance WRITE setRelativeTolerance NOTIFY relativeToleranceChanged) Q_PROPERTY(double absoluteTolerance READ absoluteTolerance WRITE setAbsoluteTolerance NOTIFY absoluteToleranceChanged) Q_PROPERTY(int threadCount READ threadCount WRITE setThreadCount NOTIFY threadCountChanged) public: explicit IntegratorModel(QObject *parent = 0); static const QString &modelJsonKey(); static const QString &startingStepSizeJsonKey(); static const QString &maximumStepSizeJsonKey(); static const QString &relativeToleranceJsonKey(); static const QString &absoluteToleranceJsonKey(); static const QString &threadCountJsonKey(); double startingStepSize() const; double maximumStepSize() const; double relativeTolerance() const; double absoluteTolerance() const; int threadCount() const; void setStartingStepSize(double startingStepSize); void setMaximumStepSize(double maximumStepSize); void setRelativeTolerance(double relativeTolerance); void setAbsoluteTolerance(double absoluteTolerance); void setThreadCount(int threadCount); void read(const QJsonObject &json); void write(QJsonObject &json) const; signals: void startingStepSizeChanged(double startingStepSize); void maximumStepSizeChanged(double maximumStepSize); void relativeToleranceChanged(double relativeTolerance); void absoluteToleranceChanged(double absoluteTolerance); void threadCountChanged(int threadCount); private: double m_startingStepSize; double m_maximumStepSize; double m_relativeTolerance; double m_absoluteTolerance; int m_threadCount; }; } // namespace staticpendulum #endif // INTEGRATORMODEL_H
/** @file FactionInfo.h (c)2013 Palestar Inc @author Jack Wallace @date 7/21/2013 */ #ifndef FACTIONINFO_H #define FACTIONINFO_H #include "World/NounContext.h" #include "GameDll.h" //--------------------------------------------------------------------------------------------------- class DLL FactionInfo : public NounContext::Data { public: DECLARE_WIDGET_CLASS(); DECLARE_PROPERTY_LIST(); typedef Reference< FactionInfo > Ref; FactionInfo() : m_nFactionInfo( -1 ) {} int m_nFactionInfo; }; #endif //--------------------------------------------------------------------------------------------------- //EOF
/* * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ /****************************************************************** iLBC Speech Coder ANSI-C Source Code WebRtcIlbcfix_Refiner.c ******************************************************************/ #include BOSS_WEBRTC_U_modules__audio_coding__codecs__ilbc__defines_h //original-code:"modules/audio_coding/codecs/ilbc/defines.h" #include BOSS_WEBRTC_U_modules__audio_coding__codecs__ilbc__constants_h //original-code:"modules/audio_coding/codecs/ilbc/constants.h" #include BOSS_WEBRTC_U_modules__audio_coding__codecs__ilbc__enh_upsample_h //original-code:"modules/audio_coding/codecs/ilbc/enh_upsample.h" #include BOSS_WEBRTC_U_modules__audio_coding__codecs__ilbc__my_corr_h //original-code:"modules/audio_coding/codecs/ilbc/my_corr.h" /*----------------------------------------------------------------* * find segment starting near idata+estSegPos that has highest * correlation with idata+centerStartPos through * idata+centerStartPos+ENH_BLOCKL-1 segment is found at a * resolution of ENH_UPSO times the original of the original * sampling rate *---------------------------------------------------------------*/ void WebRtcIlbcfix_Refiner( size_t *updStartPos, /* (o) updated start point (Q-2) */ int16_t *idata, /* (i) original data buffer */ size_t idatal, /* (i) dimension of idata */ size_t centerStartPos, /* (i) beginning center segment */ size_t estSegPos, /* (i) estimated beginning other segment (Q-2) */ int16_t *surround, /* (i/o) The contribution from this sequence summed with earlier contributions */ int16_t gain /* (i) Gain to use for this sequence */ ){ size_t estSegPosRounded, searchSegStartPos, searchSegEndPos, corrdim; size_t tloc, tloc2, i; int32_t maxtemp, scalefact; int16_t *filtStatePtr, *polyPtr; /* Stack based */ int16_t filt[7]; int32_t corrVecUps[ENH_CORRDIM*ENH_UPS0]; int32_t corrVecTemp[ENH_CORRDIM]; int16_t vect[ENH_VECTL]; int16_t corrVec[ENH_CORRDIM]; /* defining array bounds */ estSegPosRounded = (estSegPos - 2) >> 2; searchSegStartPos = (estSegPosRounded < ENH_SLOP) ? 0 : (estSegPosRounded - ENH_SLOP); searchSegEndPos = estSegPosRounded + ENH_SLOP; if ((searchSegEndPos + ENH_BLOCKL) >= idatal) { searchSegEndPos = idatal - ENH_BLOCKL - 1; } corrdim = searchSegEndPos + 1 - searchSegStartPos; /* compute upsampled correlation and find location of max */ WebRtcIlbcfix_MyCorr(corrVecTemp, idata + searchSegStartPos, corrdim + ENH_BLOCKL - 1, idata + centerStartPos, ENH_BLOCKL); /* Calculate the rescaling factor for the correlation in order to put the correlation in a int16_t vector instead */ maxtemp = WebRtcSpl_MaxAbsValueW32(corrVecTemp, corrdim); scalefact = WebRtcSpl_GetSizeInBits(maxtemp) - 15; if (scalefact > 0) { for (i = 0; i < corrdim; i++) { corrVec[i] = (int16_t)(corrVecTemp[i] >> scalefact); } } else { for (i = 0; i < corrdim; i++) { corrVec[i] = (int16_t)corrVecTemp[i]; } } /* In order to guarantee that all values are initialized */ for (i = corrdim; i < ENH_CORRDIM; i++) { corrVec[i] = 0; } /* Upsample the correlation */ WebRtcIlbcfix_EnhUpsample(corrVecUps, corrVec); /* Find maximum */ tloc = WebRtcSpl_MaxIndexW32(corrVecUps, ENH_UPS0 * corrdim); /* make vector can be upsampled without ever running outside bounds */ *updStartPos = searchSegStartPos * 4 + tloc + 4; tloc2 = (tloc + 3) >> 2; /* initialize the vector to be filtered, stuff with zeros when data is outside idata buffer */ if (ENH_FL0 > (searchSegStartPos + tloc2)) { const size_t st = ENH_FL0 - searchSegStartPos - tloc2; WebRtcSpl_MemSetW16(vect, 0, st); WEBRTC_SPL_MEMCPY_W16(&vect[st], idata, ENH_VECTL - st); } else { const size_t st = searchSegStartPos + tloc2 - ENH_FL0; if ((st + ENH_VECTL) > idatal) { const size_t en = st + ENH_VECTL - idatal; WEBRTC_SPL_MEMCPY_W16(vect, &idata[st], ENH_VECTL - en); WebRtcSpl_MemSetW16(&vect[ENH_VECTL - en], 0, en); } else { WEBRTC_SPL_MEMCPY_W16(vect, &idata[st], ENH_VECTL); } } /* compute the segment (this is actually a convolution) */ filtStatePtr = filt + 6; polyPtr = (int16_t*)WebRtcIlbcfix_kEnhPolyPhaser[tloc2 * ENH_UPS0 - tloc]; for (i = 0; i < 7; i++) { *filtStatePtr-- = *polyPtr++; } WebRtcSpl_FilterMAFastQ12(&vect[6], vect, filt, ENH_FLO_MULT2_PLUS1, ENH_BLOCKL); /* Add the contribution from this vector (scaled with gain) to the total surround vector */ WebRtcSpl_AddAffineVectorToVector(surround, vect, gain, 32768, 16, ENH_BLOCKL); return; }
/* For more information, please see: http://software.sci.utah.edu The MIT License Copyright (c) 2020 Scientific Computing and Imaging Institute, University of Utah. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #undef SCISHARE #if defined(_WIN32) && !defined(BUILD_SCIRUN_STATIC) #ifdef BUILD_Interface_Modules_Base #define SCISHARE __declspec(dllexport) #else #define SCISHARE __declspec(dllimport) #endif #else #define SCISHARE #endif
// // AppDelegate.h // // Copyright © 2016 Tokbox, Inc. All rights reserved. // #import <UIKit/UIKit.h> @class OTAcceleratorSession; @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (nonatomic, strong, readonly) OTAcceleratorSession* acceleratorSession; @end
#ifndef _UNZIP_H #define _UNZIP_H int extractZip(char *path, char *destPath); #endif
/* * Copyright (c) 2016 ETH Zurich. * All rights reserved. * * This file is distributed under the terms in the attached LICENSE file. * If you do not find this file, copies can be found by writing to: * ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group. */ #ifndef SMLT_ERROR_H_ #define SMLT_ERROR_H_ 1 /* * =========================================================================== * Smelt error values * * This is a adapted from Barrelfish's error handling * =========================================================================== */ /** * Specifies the error values that can occur */ enum smlt_err_code { SMLT_SUCCESS = 0, ///< function call succeeded SMLT_ERR_NODE_INVALD = 1, ///< there is no such node SMLT_ERR_INIT = 2, SMLT_ERR_MALLOC_FAIL = 3, ///< the allocation of memory failed SMLT_ERR_INVAL = 4, ///< invalid argument SMLT_ERR_BAD_ALIGNMENT, /* platform errors */ SMLT_ERR_PLATFORM_INIT, /* topology errors */ SMLT_ERR_TOPOLOGY_INIT, /* generator errors */ SMLT_ERR_GENERATOR, /* node errors */ SMLT_ERR_NODE_START = 5, SMLT_ERR_NODE_CREATE = 6, SMLT_ERR_NODE_JOIN = 7, /* backends */ SMLT_ERR_ALLOC_UMP, SMLT_ERR_ALLOC_FFQ, SMLT_ERR_ALLOC_SHM, SMLT_ERR_DESTROY_UMP, SMLT_ERR_DESTROY_FFQ, SMLT_ERR_DESTRYO_SHM, /* shared memory error */ SMLT_ERR_SHM_INIT = 8, /* channel error */ SMLT_ERR_CHAN_CREATE, SMLT_ERR_CHAN_DESTROY, SMLT_ERR_CHAN_WOULD_BLOCK, /* queue errors */ SMLT_ERR_QUEUE_RECV, SMLT_ERR_QUEUE_SEND, SMLT_ERR_QUEUE_STATE, SMLT_ERR_QUEUE_EMPTY, SMLT_ERR_QUEUE_FULL, SMLT_ERR_QUEUE_PREPARE, SMLT_ERR_QUEUE_INIT, /* send erros */ SMLT_ERR_SEND, SMLT_ERR_NOTIFY, SMLT_ERR }; /* * =========================================================================== * Macros * =========================================================================== */ #define SMLT_EXPECT_SUCCESS(_err, ...) \ do { \ if (smlt_err_is_fail(err)) { \ \ } \ } while(0); \ /* * =========================================================================== * Function declarations * =========================================================================== */ /** * @brief obtains the last occurred error on the error stack * * @param errval error value * * @return last occurred error */ static inline enum smlt_err_code smlt_err_no(errval_t errval) { return (((enum smlt_err_code) (errval & ((1 << 10) - 1)))); } /** * @brief checks whether the error value represents a failure * * @param errval error value to check * * @return TRUE if the value indicates a failure, FALSE if success */ static inline bool smlt_err_is_fail(errval_t errval) { return (smlt_err_no(errval) != SMLT_SUCCESS); } /** * @brief checks whether the error value represents success * * @param errval error value to check * * @return TRUE if success, FALSE on failure */ static inline bool smlt_err_is_ok(errval_t errval) { return (smlt_err_no(errval) == SMLT_SUCCESS); } /** * @brief pushes a new error onto the error value stack * * @param errval the error value stack * @param errcode the error code to push * * @return new error value stack */ static inline errval_t smlt_err_push(errval_t errval, enum smlt_err_code errcode) { return (((errval << 10) | ((errval_t) (1023 & errcode)))); } /** * @brief returns a string representation of the error code * * @param errval error value to print * * @return pointer to the string of the error code */ char* smlt_err_get_code(errval_t errval); /** * @brief prints the call trace of the errors * * @param errval error value stack */ void smlt_err_print_calltrace(errval_t errval); #endif /* SMLT_ERROR_H_ */
int missingNumber(int* nums, int numsSize) { int x = nums[0]; for (int i = 1; i < numsSize; i++) { x ^= nums[i]; } for (int i = 0; i <= numsSize; i++) { x ^= i; } return x; }
// // Generated by the J2ObjC translator. DO NOT EDIT! // source: android/libcore/luni/src/main/java/java/util/jar/JarInputStream.java // #ifndef _JavaUtilJarJarInputStream_H_ #define _JavaUtilJarJarInputStream_H_ #include "J2ObjC_header.h" #include "java/util/zip/ZipInputStream.h" @class IOSByteArray; @class JavaIoInputStream; @class JavaUtilJarJarEntry; @class JavaUtilJarManifest; @class JavaUtilZipZipEntry; /*! @brief The input stream from which the JAR file to be read may be fetched. It is used like the <code>ZipInputStream</code>. */ @interface JavaUtilJarJarInputStream : JavaUtilZipZipInputStream #pragma mark Public /*! @brief Constructs a new <code>JarInputStream</code> from an input stream. @param stream the input stream containing the JAR file. @throws IOException If an error occurs reading entries from the input stream. */ - (instancetype)initWithJavaIoInputStream:(JavaIoInputStream *)stream; /*! @brief Constructs a new <code>JarInputStream</code> from an input stream. @param stream the input stream containing the JAR file. @param verify if the file should be verified with a <code>JarVerifier</code>. @throws IOException If an error occurs reading entries from the input stream. */ - (instancetype)initWithJavaIoInputStream:(JavaIoInputStream *)stream withBoolean:(jboolean)verify; - (void)closeEntry; /*! @brief Returns the <code>Manifest</code> object associated with this <code>JarInputStream</code> or <code>null</code> if no manifest entry exists. @return the MANIFEST specifying the contents of the JAR file. */ - (JavaUtilJarManifest *)getManifest; /*! @brief Returns the next <code>ZipEntry</code> contained in this stream or <code>null</code> if no more entries are present. @return the next extracted ZIP entry. @throws IOException if an error occurs while reading the entry. */ - (JavaUtilZipZipEntry *)getNextEntry; /*! @brief Returns the next <code>JarEntry</code> contained in this stream or <code>null</code> if no more entries are present. @return the next JAR entry. @throws IOException if an error occurs while reading the entry. */ - (JavaUtilJarJarEntry *)getNextJarEntry; /*! @brief Reads up to <code>byteCount</code> bytes of decompressed data and stores it in <code>buffer</code> starting at <code>byteOffset</code>. Returns the number of uncompressed bytes read. @throws IOException if an IOException occurs. */ - (jint)readWithByteArray:(IOSByteArray *)buffer withInt:(jint)byteOffset withInt:(jint)byteCount; #pragma mark Protected - (JavaUtilZipZipEntry *)createZipEntryWithNSString:(NSString *)name; @end J2OBJC_EMPTY_STATIC_INIT(JavaUtilJarJarInputStream) FOUNDATION_EXPORT void JavaUtilJarJarInputStream_initWithJavaIoInputStream_withBoolean_(JavaUtilJarJarInputStream *self, JavaIoInputStream *stream, jboolean verify); FOUNDATION_EXPORT JavaUtilJarJarInputStream *new_JavaUtilJarJarInputStream_initWithJavaIoInputStream_withBoolean_(JavaIoInputStream *stream, jboolean verify) NS_RETURNS_RETAINED; FOUNDATION_EXPORT void JavaUtilJarJarInputStream_initWithJavaIoInputStream_(JavaUtilJarJarInputStream *self, JavaIoInputStream *stream); FOUNDATION_EXPORT JavaUtilJarJarInputStream *new_JavaUtilJarJarInputStream_initWithJavaIoInputStream_(JavaIoInputStream *stream) NS_RETURNS_RETAINED; J2OBJC_TYPE_LITERAL_HEADER(JavaUtilJarJarInputStream) #endif // _JavaUtilJarJarInputStream_H_
/** ****************************************************************************** * @file Projects/Multi/Examples/IKS01A1/LSM6DS3_FIFOLowPower/Src/stm32l0xx_it.c * @author CL * @version V4.0.0 * @date 1-May-2017 * @brief Main Interrupt Service Routines. * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2> * * 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. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * 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. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "stm32l0xx_it.h" #include "main.h" /** @addtogroup X_NUCLEO_IKS01A1_Examples * @{ */ /** @addtogroup FIFO_LOW_POWER * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M0+ Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception * @param None * @retval None */ void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /** * @brief This function handles Debug Monitor exception * @param None * @retval None */ void DebugMon_Handler(void) { } /** * @brief This function handles SysTick Handler * @param None * @retval None */ void SysTick_Handler(void) { HAL_IncTick(); } /******************************************************************************/ /* STM32L0xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32l0xx.s). */ /******************************************************************************/ /** * @brief This function handles External lines 4 to 15 interrupt request * @param None * @retval None */ void EXTI4_15_IRQHandler(void) { HAL_GPIO_EXTI_IRQHandler(M_INT1_PIN); HAL_GPIO_EXTI_IRQHandler(KEY_BUTTON_PIN); } /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#ifndef FACET_SIX_H #define FACET_SIX_H #ifdef __cplusplus extern "C"{ #endif #include <stddef.h> #include "honeycomb_types.h" #undef BEE_64 /** * This structure is a context for HoneyComb Facet #6 computations: it contains the * intermediate values and some data from the last entered block. Once * an HoneyComb Facet #6 computation has been performed, the context can be reused for * another computation. This specific structure is used for HoneyComb Facet #6. * * The contents of this structure are private. A running HoneyComb Facet #6 computation * can be cloned by copying the context (e.g. with a simple memcpy()). */ typedef struct { unsigned char buf[128]; /* first field, for alignment */ size_t ptr; union { bee_u32 Vs[8][4]; #if BEE_64 bee_u64 Vb[8][2]; #endif } u; bee_u32 C0, C1, C2, C3; } facet_six_context; /** * Initialize an HoneyComb Facet #6 context. This process performs no memory allocation. * * @param cc the HoneyComb Facet #6 context (pointer to a facet_six_context ) */ void facet_six_init(void *cc); /** * Process some data bytes. It is acceptable that len is zero * (in which case this function does nothing). * * @param cc the HoneyComb Facet #6 context * @param data the input data * @param len the input data length (in bytes) */ void facet_six(void *cc, const void *data, size_t len); /** * Terminate the current HoneyComb Facet #6 computation and output the result into * the provided buffer. The destination buffer must be wide enough to * accomodate the result (64 bytes). The context is automatically reinitialized. * * @param cc the HoneyComb Facet #6 context * @param dst the destination buffer */ void facet_six_close(void *cc, void *dst); /** * Add a few additional bits (0 to 7) to the current computation, then * terminate it and output the result in the provided buffer, which must * be wide enough to accomodate the result (64 bytes). If bit number i * in ub has value 2^i, then the extra bits are those * numbered 7 downto 8-n (this is the big-endian convention at the byte * level). The context is automatically reinitialized. * * @param cc the HoneyComb Facet #6 context * @param ub the extra bits * @param n the number of extra bits (0 to 7) * @param dst the destination buffer */ void facet_six_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst); #ifdef __cplusplus } #endif #endif
/**************************************************************************** * * Copyright (c) 2016 PX4 Development Team. 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. * 3. Neither the name PX4 nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * 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 OWNER 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. * ****************************************************************************/ /** * @file syslink.c * * Crazyflie Syslink protocol implementation * * @author Dennis Shtatnov <densht@gmail.com> */ #include <px4_defines.h> #include <fcntl.h> #include <stdio.h> #include <sys/ioctl.h> #include <systemlib/err.h> #include <poll.h> #include <termios.h> #include "syslink.h" const char *syslink_magic = "\xbc\xcf"; void syslink_parse_init(syslink_parse_state *state) { state->state = SYSLINK_STATE_START; state->index = 0; } int syslink_parse_char(syslink_parse_state *state, char c, syslink_message_t *msg) { switch (state->state) { case SYSLINK_STATE_START: if (c == syslink_magic[state->index]) { state->index++; } else { state->index = 0; } if (syslink_magic[state->index] == '\x00') { state->state = SYSLINK_STATE_TYPE; } break; case SYSLINK_STATE_TYPE: msg->type = c; state->state = SYSLINK_STATE_LENGTH; break; case SYSLINK_STATE_LENGTH: msg->length = c; if (c > SYSLINK_MAX_DATA_LEN) { // Too long state->state = SYSLINK_STATE_START; } else { state->state = c > 0 ? SYSLINK_STATE_DATA : SYSLINK_STATE_CKSUM; } state->index = 0; break; case SYSLINK_STATE_DATA: msg->data[state->index++] = c; if (state->index >= msg->length) { state->state = SYSLINK_STATE_CKSUM; state->index = 0; syslink_compute_cksum(msg); } break; case SYSLINK_STATE_CKSUM: if (c != msg->cksum[state->index]) { PX4_INFO("Bad checksum"); state->state = SYSLINK_STATE_START; state->index = 0; break; } state->index++; if (state->index >= sizeof(msg->cksum)) { state->state = SYSLINK_STATE_START; state->index = 0; return 1; } break; } return 0; } /* Computes Fletcher 8bit checksum per RFC1146 A := A + D[i] B := B + A */ void syslink_compute_cksum(syslink_message_t *msg) { uint8_t a = 0, b = 0; uint8_t *Di = (uint8_t *)msg, *end = Di + (2 + msg->length) * sizeof(uint8_t); while (Di < end) { a = a + *Di; b = b + a; ++Di; } msg->cksum[0] = a; msg->cksum[1] = b; }
// // SSCollectionView.h // SSToolkit // // Created by Sam Soffes on 6/11/10. // Copyright 2009-2010 Sam Soffes. All rights reserved. // #import "SSCollectionViewItem.h" @protocol SSCollectionViewDelegate; @protocol SSCollectionViewDataSource; /** @brief Simple collection view. This is very alphay. My goals are to be similar to UITableView and NSCollectionView when possible. Currently it's pretty inefficient and doesn't reuse items and all items have to be the same size. Only scrolling vertically is currently supported. Multiple sections are not supported. Editing and performance will be my next focus. Then animating changes when data changes and an option to disable that. */ @interface SSCollectionView : UIScrollView { id <SSCollectionViewDataSource> _dataSource; CGFloat _rowHeight; CGFloat _rowSpacing; CGFloat _columnWidth; CGFloat _columnSpacing; UIView *_backgroundView; UIView *_backgroundHeaderView; UIView *_backgroundFooterView; NSUInteger _minNumberOfColumns; NSUInteger _maxNumberOfColumns; CGSize _minItemSize; CGSize _maxItemSize; BOOL _allowsSelection; @protected NSMutableArray *_items; } /** @brief The object that acts as the data source of the receiving collection view. */ @property (nonatomic, assign) id<SSCollectionViewDataSource> dataSource; /** @brief The object that acts as the delegate of the receiving collection view. */ @property (nonatomic, assign) id<SSCollectionViewDelegate, UIScrollViewDelegate> delegate; /** @brief The height of each row in the receiver. The row height is in points. The default is 80. */ @property (nonatomic, assign) CGFloat rowHeight; /** @brief The spacing between each row in the receiver. This does not add space above the first row or below the last. The row spacing is in points. The default is 20. */ @property (nonatomic, assign) CGFloat rowSpacing; /** @brief The width of each column in the receiver. The column width is in points. The default is 80. */ @property (nonatomic, assign) CGFloat columnWidth; /** @brief The spacing between each column in the receiver. This does not add space to the left of the first column or the right of the last column. The column spacing is in points. The default is 20. */ @property (nonatomic, assign) CGFloat columnSpacing; /** @brief The background view of the collection view. */ @property (nonatomic, retain) UIView *backgroundView; @property (nonatomic, retain) UIView *backgroundHeaderView; @property (nonatomic, retain) UIView *backgroundFooterView; @property (nonatomic, assign) NSUInteger minNumberOfColumns; @property (nonatomic, assign) NSUInteger maxNumberOfColumns; @property (nonatomic, assign) CGSize minItemSize; @property (nonatomic, assign) CGSize maxItemSize; /** @brief A Boolean value that determines whether selecting items is enabled. If the value of this property is <code>YES</code>, selecting is enabled, and if it is <code>NO</code>, selecting is disabled. The default is <code>YES</code>. */ @property (nonatomic, assign) BOOL allowsSelection; /** @brief Reloads the items and sections of the receiver. */ - (void)reloadData; /** @brief Returns a reusable collection view item object located by its identifier. @param identifier A string identifying the cell object to be reused. @return A SSCollectionViewItem object with the associated identifier or nil if no such object exists in the reusable-item queue. */ - (SSCollectionViewItem *)dequeueReusableItemWithIdentifier:(NSString *)identifier; /** @brief Returns the collection view item at the specified index path. @param indexPath The index path locating the item in the receiver. @return An object representing a cell of the table or nil if the cell is not visible or indexPath is out of range. @see indexPathForItem: */ - (SSCollectionViewItem *)itemPathForIndex:(NSIndexPath *)indexPath; /** @brief Returns an index path representing the row (index) and section of a given collection view item. @param item An item object of the collection view. @return An index path representing the row and section of the cell or nil if the index path is invalid. @see itemPathForIndex: */ - (NSIndexPath *)indexPathForItem:(SSCollectionViewItem *)item; /** @brief Deselects a given item identified by index path, with an option to animate the deselection. <strong>Currently not implemented.</strong> @param indexPath An index path identifying an item in the receiver. @param animated <code>YES</code> if you want to animate the deselection and <code>NO</code> if the change should be immediate. */ - (void)deselectItemAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated; /** @brief Scrolls the receiver until a row identified by index path is at a particular location on the screen. @param indexPath An index path that identifies an item in the collection view by its row index and its section index. @param animated <code>YES</code> if you want to animate the deselection and <code>NO</code> if the change should be immediate. */ - (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated; /** @brief Reloads the specified item. @param indexPath An index path that identifies an item in the collection view by its row index and its section index. */ - (void)reloadItemAtIndexPaths:(NSIndexPath *)indexPaths; @end @protocol SSCollectionViewDataSource <NSObject> @required - (NSUInteger)collectionView:(SSCollectionView *)aCollectionView numberOfRowsInSection:(NSInteger)section; - (SSCollectionViewItem *)collectionView:(SSCollectionView *)aCollectionView itemForIndexPath:(NSIndexPath *)indexPath; @end @protocol SSCollectionViewDelegate <NSObject, UIScrollViewDelegate> @optional - (CGFloat)collectionView:(SSCollectionView *)aCollectionView heightForHeaderInSection:(NSInteger)section; - (CGFloat)collectionView:(SSCollectionView *)aCollectionView heightForFooterInSection:(NSInteger)section; - (void)collectionView:(SSCollectionView *)aCollectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath; @end
#ifndef __ml_InstanceBasedSupervisedLearner__ #define __ml_InstanceBasedSupervisedLearner__ #include "NearestNeighborSet.h" #include "RowListUtil.h" #include "learner.h" #include "rand.h" #include "matrix.h" namespace ml { class InstanceBasedSupervisedLearner : public SupervisedLearner { public: InstanceBasedSupervisedLearner(const Rand & r, int k, bool weight, double reduction); virtual ~InstanceBasedSupervisedLearner(); virtual void train(Matrix& features, Matrix& labels, Matrix *testSet, Matrix * testLabels); virtual void predict(const std::vector<double>& features, std::vector<double>& labels); private: Rand rand; int K; std::vector<RowList> lists; std::vector<NearestNeighborSet*> NNSets; Matrix Features; std::vector<std::pair<std::size_t, double> > FeatureAttributes; bool InverseSquare; double ReductionTerm; void free(); }; } #endif // __ml_InstanceBasedSupervisedLearner__
// // SVBaseViewController.h // SVPullToRefreshDemo // // Created by KudoCC on 16/1/1. // Copyright © 2016年 https://github.com/kudocc. All rights reserved. // #import <UIKit/UIKit.h> #import "SVMacroDefine.h" @interface SVBaseViewController : UIViewController @end @interface SVBaseViewController (override_method) - (void)initView; - (void)initData; @end
/* Copyright ©2007-2010 Kris Maglione <maglione.k at Gmail> * See LICENSE file for license details. */ #include <stuff/geom.h> #include <langinfo.h> #include <stdarg.h> #include <bio.h> #include <fmt.h> #include <regexp9.h> /* Types */ typedef struct Regex Regex; struct Regex { char* regex; Reprog* regc; }; enum { CLeft = 1<<0, CCenter = 1<<1, CRight = 1<<2, }; enum { GInvert = 1<<0, }; #define utf8locale() (!strcmp(nl_langinfo(CODESET), "UTF-8")) #ifdef VARARGCK # pragma varargck argpos _die 3 # pragma varargck argpos fatal 1 # pragma varargck argpos sxprint 1 #endif #define strlcat stuff_strlcat #define strcasestr stuff_strcasestr int Blprint(Biobuf*, const char*, ...); int Bvlprint(Biobuf*, const char*, va_list); void _die(char*, int, char*, ...); void backtrace(char*); void closeexec(int); char** comm(int, char**, char**); int doublefork(void); void* emalloc(uint); void* emallocz(uint); void* erealloc(void*, uint); char* estrdup(const char*); char* estrndup(const char*, uint); __attribute__((noreturn)) void fatal(const char*, ...); Fmt fmtbuf(char*, int); void* freelater(void*); int getbase(const char**, long*); bool getint(const char*, int*); bool getlong(const char*, long*); bool getulong(const char*, ulong*); void grep(char**, Reprog*, int); char* join(char**, char*, Fmt*); int localefmt(Fmt*); void localefmtinstall(void); int localelen(char*, char*); int lprint(int, const char*, ...); int max(int, int); int min(int, int); uvlong nsec(void); char* pathsearch(const char*, const char*, bool); void refree(Regex*); void reinit(Regex*, char*); int spawn3(int[3], const char*, char*[]); int spawn3l(int[3], const char*, ...); uint stokenize(char**, uint, char*, char*); char* strcasestr(const char*, const char*); char* strend(char*, int); uint strlcat(char*, const char*, uint); int strlcatprint(char*, int, const char*, ...); char* sxprint(const char*, ...); uint tokenize(char**, uint, char*, char); void trim(char *str, const char *chars); void uniq(char**); int unmask(Fmt*, long, char**, long); int unquote(char*, char*[], int); int utflcpy(char*, const char*, int); int vlprint(int, const char*, va_list); char* vsxprint(const char*, va_list); extern char* _buffer; extern char buffer[8092]; extern char* const _buf_end; #define bufclear() \ BLOCK( _buffer = buffer; _buffer[0] = '\0' ) #define bufprint(...) \ _buffer = seprint(_buffer, _buf_end, __VA_ARGS__) #define die(...) \ _die(__FILE__, __LINE__, __VA_ARGS__) extern char *argv0; #undef ARGBEGIN #undef ARGEND #undef ARGF #undef EARGF #define ARGBEGIN \ int _argtmp=0, _inargv; char *_argv=nil; \ if(!argv0) argv0=*argv; argv++, argc--; \ _inargv=1; USED(_inargv); \ while(argc && argv[0][0] == '-') { \ _argv=&argv[0][1]; argv++; argc--; \ if(_argv[0] == '-' && _argv[1] == '\0') \ break; \ while(*_argv) switch(*_argv++) #define ARGEND }_inargv=0;USED(_argtmp, _argv, _inargv) #define EARGF(f) ((_inargv && *_argv) ? \ (_argtmp=strlen(_argv), _argv+=_argtmp, _argv-_argtmp) \ : ((argc > 0) ? \ (--argc, ++argv, _used(argc), *(argv-1)) \ : ((f), (char*)0))) #define ARGF() EARGF(_used(0)) /* map.c */ typedef struct Map Map; typedef struct MapEnt MapEnt; struct Map { MapEnt**bucket; uint nhash; uint nmemb; }; void** hash_get(Map*, const char*, bool create); void* hash_rm(Map*, const char*); void** map_get(Map*, ulong, bool create); void* map_rm(Map*, ulong); /* Yuck. */ #define VECTOR(type, nam, c) \ typedef struct Vector_##nam Vector_##nam; \ struct Vector_##nam { \ type* ary; \ long n; \ long size; \ }; \ void vector_##c##free(Vector_##nam*); \ void vector_##c##init(Vector_##nam*); \ void vector_##c##push(Vector_##nam*, type); \ VECTOR(long, long, l) VECTOR(Rectangle, rect, r) VECTOR(void*, ptr, p) #undef VECTOR
// // HTHorizontalSelectionList.h // Hightower // // Created by Erik Ackermann on 7/31/14. // Copyright (c) 2014 Hightower Inc. All rights reserved. // @import UIKit; @protocol HTHorizontalSelectionListDataSource; @protocol HTHorizontalSelectionListDelegate; typedef NS_ENUM(NSInteger, HTHorizontalSelectionIndicatorStyle) { HTHorizontalSelectionIndicatorStyleBottomBar, // Default HTHorizontalSelectionIndicatorStyleButtonBorder, HTHorizontalSelectionIndicatorStyleNone }; typedef NS_ENUM(NSInteger, HTHorizontalSelectionIndicatorAnimationMode) { HTHorizontalSelectionIndicatorAnimationModeHeavyBounce, // Default HTHorizontalSelectionIndicatorAnimationModeLightBounce, HTHorizontalSelectionIndicatorAnimationModeNoBounce }; @interface HTHorizontalSelectionList : UIView /** Returns selected button index. -1 if nothing selected to animate this change, use `-setSelectedButtonIndex:animated:` NOTE: this value will persist between calls to `-reloadData` */ @property (nonatomic) NSInteger selectedButtonIndex; @property (nonatomic, weak) id<HTHorizontalSelectionListDataSource> dataSource; @property (nonatomic, weak) id<HTHorizontalSelectionListDelegate> delegate; @property (nonatomic) CGFloat selectionIndicatorHeight; @property (nonatomic) CGFloat selectionIndicatorHorizontalPadding; @property (nonatomic, strong) UIColor *selectionIndicatorColor; @property (nonatomic, strong) UIColor *bottomTrimColor; /// Default is NO @property (nonatomic) BOOL bottomTrimHidden; /// Default is NO. Only has an affect if the number of buttons if the selection list does not fill the space horizontally. @property (nonatomic) BOOL centerAlignButtons; /// Default is NO. If YES, center all items on selection. @property (nonatomic) BOOL centerOnSelection; /// Default is NO. If YES, center item is automatically selected when control is initialized. @property (nonatomic) BOOL autoselectCentralItem; /// Default is NO. If YES, corrects position to center after dragging. @property (nonatomic) BOOL autocorrectCentralItemSelection; /// Default is NO. If set to YES, the buttons will fade away near the edges of the list. @property (nonatomic) BOOL showsEdgeFadeEffect; @property (nonatomic) HTHorizontalSelectionIndicatorAnimationMode selectionIndicatorAnimationMode; @property (nonatomic) UIEdgeInsets buttonInsets; @property (nonatomic) HTHorizontalSelectionIndicatorStyle selectionIndicatorStyle; - (void)setTitleColor:(UIColor *)color forState:(UIControlState)state; - (void)setTitleFont:(UIFont *)font forState:(UIControlState)state; - (void)reloadData; - (void)setSelectedButtonIndex:(NSInteger)selectedButtonIndex animated:(BOOL)animated; - (void)scrollToIndex:(NSInteger)index; @end @protocol HTHorizontalSelectionListDataSource <NSObject> - (NSInteger)numberOfItemsInSelectionList:(HTHorizontalSelectionList *)selectionList; @optional - (NSString *)selectionList:(HTHorizontalSelectionList *)selectionList titleForItemWithIndex:(NSInteger)index; - (UIView *)selectionList:(HTHorizontalSelectionList *)selectionList viewForItemWithIndex:(NSInteger)index; @end @protocol HTHorizontalSelectionListDelegate <NSObject> - (void)selectionList:(HTHorizontalSelectionList *)selectionList didSelectButtonWithIndex:(NSInteger)index; @end
// // Created by Administrator on 2017-5-16. // #ifndef TOMATO_H #define TOMATO_H //#include <string> #include <QWidget> #include <QLabel> #include <QPushButton> #include <QVBoxLayout> #include <QByteArray> //#include <QCheckBox> //#include <QtWinExtras> #include <QWinTaskbarButton> #include <QWinTaskbarProgress> //#include "config.h" #include "lineedit.h" //using namespace std; class Tomato : public QWidget { Q_OBJECT public: Tomato(QWidget *parent=0); ~Tomato(); //QString name = "番茄倒计时"; //static name = "番茄倒计时"; //static const QString name = "番茄倒计时"; //const QString name = "番茄倒计时"; //static QString name = "番茄倒计时"; static QString name; //static int name = reinterpret_cast<int *>(QString("番茄倒计时")); //static int * name = reinterpret_cast<int *>(QString("番茄倒计时")); //static char * name = reinterpret_cast<char *>(QString("番茄倒计时")); //static char * name = reinterpret_cast<char *>("番茄倒计时"); //static char * name = const_cast<char *>("番茄倒计时"); //static char * name = static_cast<char *>("番茄倒计时"); //static char * name = dynamic_cast<char *>("番茄倒计时"); //E:\develop\QtProjects\TomatoDownWidgets\tomato.h:34: error: reinterpret_cast from type 'const char*' to type 'char*' casts away qualifiers //static char * name = reinterpret_cast<char *>(); //static string name = "番茄倒计时"; //static QByteArray name = QByteArray("番茄倒计时"); bool initiated = false; int width = 500; int height = 300; int labelMinWidth = 50; int inputWidth = 40; int unitWidth = 25; int buttonWidth = 40; int itemHeight = 35; //int increase = 1; //bool increase = true; bool increase = false; //QCheckBox *increaseCheckBox; bool autoStart = true; //bool autoStart = false; // 任务栏图标进度条状态 enum State { Normal = 1, Pause = 2, Stop = 3, }; State state; // 计时状态 enum CountState { CountInit = 10, CountInProgress = 11, CountPause = 12, CountStop = 13, CountBreak = 20, CountOvertime = 25, }; CountState countState; /* init: 初始状态 in progress: 进行中 pause: 暂停 stop: 停止 break: 休息 overtime: 超时 */ QPushButton *startButton; QPushButton *restartButton; QPushButton *continueButton; QPushButton *pauseButton; QPushButton *stopButton; QPushButton *breakButton; QPushButton *addButton; QMap<QString, QVariant> row; QLabel *progress; QLabel *to; //QPixmap *icon; //QPixmap icon; //QPainter *painter; qint64 lastOverlayMin = -1; LineEdit *inputTime; LineEdit *inputTipTime; LineEdit *inputBreakTime; //QHash<QString, QVariant> settings; //QHash<QString, QVariant> newSettings; //QHash<QString, QVariant> oldSettings; QMap<QString, QVariant> settings; QMap<QString, QVariant> newSettings; QMap<QString, QVariant> oldSettings; QHash<QString, bool> delayedActions; // 没有设置的值获取时是false QString keySaveSetting = "saveSetting"; //QMap<QString, QString> fields; //QList<QString, QTimer *> timer; QHash<QString, QTimer *> timer; QHash<QString, qint64> timeConsumed; QString key = "one"; // 一条计时数据保存使用的key,便于以后扩展成多个计时 void createTimer(QString timerKey); QWinTaskbarButton *taskbarButton; QWinTaskbarProgress *taskbarProgress; // 为了能看清任务栏图标上进度条的颜色,限制其最小值 int progressMinValue = 50; void setOverlayIcon(int min); void setTaskbarProgress(State state, int value, int maxValue); //void setTaskbarProgress(int state, int value, int maxValue); QString paddingZero(qint64 i); qint64 getSecondsSince(QDateTime time); void setCountState(CountState state); QVBoxLayout *rightLayout; //void beginSaveSetting(); void beginSaveCountMode(); public slots: void startCountDown(); void restart(); void continueCountDown(); void pause(); void stop(); void startBreak(); void countDown(); //void increaseChanged(Qt::CheckState state); //void increaseChanged(int state); void countModeChanged(int state); void autoStartChanged(int state); void addButtonClicked(); void endSaveSetting(); void endSaveCountMode(); private: void setControlButtonVisibility(); void beginSaveSetting(); }; #endif //TOMATO_H
// // PMAccountManager.h // ObjectivePoGo // // Created by 43f9879ddabcb80a685cf0e269a0bfca1e52786dee41c38604ae3b28a9d53657 on 2016-08-17. // Copyright © 2016 f6da75852aea28f8213466482daa395c113ec503406009dcaf1659e8139d4e56. All rights reserved. // #import <Foundation/Foundation.h> #import "PGAccount.h" #import "PGAccountInfo.h" @interface PGAccountManager : NSObject @property (readonly, nonatomic) NSUInteger activeAccountsCount; + (PGAccountManager *)sharedInstance; - (void)loginWithAccountInfo:(PGAccountInfo *)accountInfo completion:(PGAccountCompletion)completion __deprecated_msg("use 'loginWithAccountInfo:atCoordinate:completion:' instead"); - (void)loginWithAccountInfo:(PGAccountInfo *)accountInfo atCoordinate:(CLLocationCoordinate2D)coordinate completion:(PGAccountCompletion)completion; - (void)queryMapWithCoordinate:(CLLocationCoordinate2D)coordinate completion:(PGMapObjectsCompletion)completion; - (void)queryMapWithCellId:(uint64_t)cellId coordinate:(CLLocationCoordinate2D)coordinate completion:(PGMapObjectsCompletion)completion; @end
// // Note.h // Noter // // Created by hyou on 3/6/13. // Copyright (c) 2013 Xun Gong. All rights reserved. // /** * Type: Sort by type first, so 'starred' will be put on top, thus need alphabetic order on different * types. Currently potential types are: * starred, "" */ #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @class Media; @interface Note : NSManagedObject @property (nonatomic, retain) NSDate * eventDate; @property (nonatomic, retain) NSString * text; @property (nonatomic, retain) NSString * type; @property (nonatomic, retain) NSDate * updateDate; @property (nonatomic, retain) NSSet *media; @end @interface Note (CoreDataGeneratedAccessors) - (void)addMediaObject:(Media *)value; - (void)removeMediaObject:(Media *)value; - (void)addMedia:(NSSet *)values; - (void)removeMedia:(NSSet *)values; @end
#ifndef _EASYEDITOR_DRAG_PHYSICS_OP_H_ #define _EASYEDITOR_DRAG_PHYSICS_OP_H_ #include "ZoomViewOP.h" #include <SM_Vector.h> #include <Box2D/Box2D.h> namespace ee { class DragPhysicsOP : public ZoomViewOP { public: DragPhysicsOP(wxWindow* wnd, EditPanelImpl* stage, b2World* world, b2Body* ground); virtual bool OnMouseLeftDown(int x, int y) override; virtual bool OnMouseLeftUp(int x, int y) override; virtual bool OnMouseDrag(int x, int y) override; private: b2World* m_world; b2Body* m_ground; public: b2MouseJoint* m_mouseJoint; sm::vec2 m_curr_pos; }; // DragPhysicsOP } #endif // _EASYEDITOR_DRAG_PHYSICS_OP_H_
#ifndef CMARK_PARSER_H #define CMARK_PARSER_H #include <stdio.h> #include "node.h" #include "buffer.h" #include "memory.h" #ifdef __cplusplus extern "C" { #endif #define MAX_LINK_LABEL_LENGTH 1000 void cmark_parser_init(cmark_parser *parser); void cmark_parser_deinit(cmark_parser *parser); void cmark_render_html_out(cmark_strbuf *buff, cmark_node *root, int options); struct cmark_parser { /* A hashtable of urls in the current document for cross-references */ struct cmark_reference_map *refmap; /* The root node of the parser, always a CMARK_NODE_DOCUMENT */ struct cmark_node *root; /* The last open block after a line is fully processed */ struct cmark_node *current; /* See the documentation for cmark_parser_get_line_number() in cmark.h */ int line_number; /* See the documentation for cmark_parser_get_offset() in cmark.h */ bufsize_t offset; /* See the documentation for cmark_parser_get_column() in cmark.h */ bufsize_t column; /* See the documentation for cmark_parser_get_first_nonspace() in cmark.h */ bufsize_t first_nonspace; /* See the documentation for cmark_parser_get_first_nonspace_column() in cmark.h */ bufsize_t first_nonspace_column; /* See the documentation for cmark_parser_get_indent() in cmark.h */ int indent; /* See the documentation for cmark_parser_is_blank() in cmark.h */ bool blank; /* See the documentation for cmark_parser_has_partially_consumed_tab() in cmark.h */ bool partially_consumed_tab; /* Contains the currently processed line */ cmark_strbuf curline; /* See the documentation for cmark_parser_get_last_line_length() in cmark.h */ bufsize_t last_line_length; /* FIXME: not sure about the difference with curline */ cmark_strbuf linebuf; /* Options set by the user, see the Options section in cmark.h */ bool last_buffer_ended_with_cr; cmark_ispunct_func backslash_ispunct; int options; struct cmark_mem *mem; cmark_llist *syntax_extensions; cmark_llist *inline_syntax_extensions; }; #ifdef __cplusplus } #endif #endif
// // PLABViewController.h // ElegantTimePickerExample // // Created by Longyi Li on 8/15/14. // Copyright (c) 2014 PhantomLab. All rights reserved. // #import <UIKit/UIKit.h> @interface PLABViewController : UIViewController @end
/* * The MIT License (MIT) * * Copyright (c) 2018 Johan Kanflo (github.com/kanflo) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #ifndef __FUNC_CC_H__ #define __FUNC_CC_H__ #include "uui.h" /** * @brief Add the CV function to the UI * * @param ui The user interface */ void func_cc_init(uui_t *ui); #endif // __FUNC_CC_H__
#include "testUIP.h" #if LO_TEST_UIP #include <stdio.h> #include <string.h> #include "MadOS.h" #include "uTcp.h" static uTcp *sock; static MadUint cnt_acked = 0; static MadUint cnt_rexmit = 0; static int tcp_recv(uTcp *s, MadU8 *data, MadU16 len); static int tcp_ack(uTcp *s, MadBool flag); static void tcp_send(void); void Init_TestUIP(void) { const MadU8 target_ip[4] = {192, 168, 1, 122}; sock = uTcp_Create(target_ip, 5688, tcp_recv, tcp_ack); } int tcp_recv(uTcp *s, MadU8 *data, MadU16 len) { (void)s; const char dst[] = "Hello MadOS"; if(0 == madMemCmp(dst, (const char *)uip_appdata, sizeof(dst) - 1)) { tcp_send(); } return 0; } int tcp_ack(uTcp *s, MadBool flag) { (void)s; if(!flag) { cnt_rexmit++; tcp_send(); } else { cnt_acked++; } return 0; } void tcp_send(void) { MadU8 *buf = (MadU8*)uip_appdata; MadU32 len = sprintf((char*)buf, "uIP -> Acked[%d], Rexmit[%d]", cnt_acked, cnt_rexmit); uip_send(uip_appdata, len); } #endif
// // AppDelegate.h // WXSGithubApp // // Created by 王小树 on 17/3/1. // Copyright © 2017年 王小树. All rights reserved. // #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
#ifndef INCLUDE_LINTERINTERP #define INCLUDE_LINTERINTERP #include <cmath> /** a linear interp where the domain is pot values: 0.. 0x3ff * however: we want all step even sized. so, for example * if range is 1..4 * 0..3ff/4 -> 1/2 cutover * 0..3ff/2 -> 2/3 cutover * 0..3*3ff/4 -> 3/4 cutover */ // straight interp #if 0 class LinearInterp { public: LinearInterp(int y0, int y1) { // we can get the desired even spacing by mapping x1+1 to y1+1 //_a= (double)((y1+1) - y0) / (double)(0x3ff + 1); //const int delta_y = (y1 > y0) ? 1 : -1; //const int delta_y = 1; //_a= (double)((y1+delta_y) - y0) / (double)(0x3ff + 1); // simple way _a= (double)(y1 - y0) / (double)(0x3ff ); _b= y0; //printf("\ninit %d,%d a=%f b=%f\n", y0, y1, _a, _b); } int interp(int x) const { double d = _a * x + _b; int ret = (int) d; //printf("li (%d) ret %f (%d)\n", x, d, ret); return ret; } private: double _a; double _b; }; #endif // attemp at even spacing #if 0 class LinearInterp { public: LinearInterp(int y0, int y1) { const int _y0 = y0; const int _y1 = y1; int x0 = 0; int x1 = 0x3ff; // adjust one end so we get even spacing when we round down if (y1 > y0) { y1++; x1++; } else { y0++; x0--; } _a= (double)(y1 - y0) / (double)(x1 - x0 ); _b= y0 - _a * x0; printf("\ninit %d,%d a=%f b=%f\n", _y0, _y1, _a, _b); printf(" modified x: %d,%d y:%d,%d\n", x0, x1, y0, y1); } int interp(int x) const { double d = _a * x + _b; int ret = (int)std::floor(d); //int ret = (int) d; printf("li (%d) ret %f (%d)\n", x, d, ret); return ret; } private: double _a; double _b; }; #endif #include "FixedPoint.h" // even spacing fixed point // Meant for discrete steps (not continous re-map), althouth it will work fine for continuous // Uses fixed point, so it's pretty fast // Domain is z pot range 0..3ff class LinearInterp { public: LinearInterp(int y0, int y1) { const int _y0 = y0; const int _y1 = y1; int x0 = 0; int x1 = 0x3ff; // adjust one end so we get even spacing when we round down if (y1 > y0) { y1++; x1++; } else { y0++; x0--; } float a= (float)((double)(y1 - y0) / (double)(x1 - x0 )); float b= y0 - a * x0; _a = fp::fromFloat(a); _b = fp::fromFloat(b); } int interp(int x) const { fp _x = fp::fromInt(x); fp d = _a.mul( _x).add(_b); int ret = d.toInt(); // printf("li (%d) ret %f (%d)\n", x, d.toFloat(), ret); return ret; } private: const static int precission =16; typedef FixedPoint<precission> fp; fp _a; fp _b; }; class InterpForLED : public LinearInterp { public: InterpForLED() : LinearInterp(1, 15) {} }; #endif
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "CDStructures.h" #import "DVTPropertyListEncoding-Protocol.h" @class DVTExtensionElementDescription, DVTPlugIn, DVTPlugInManager, NSBundle, NSDictionary, NSMutableSet, NSSet, NSString; @interface DVTExtensionPoint : NSObject <DVTPropertyListEncoding> { NSDictionary *_extensionPointData; DVTPlugInManager *_plugInManager; NSString *_identifier; NSString *_version; NSString *_name; DVTPlugIn *_plugIn; DVTExtensionElementDescription *_extensionSchema; DVTExtensionPoint *_parentExtensionPoint; NSMutableSet *_extensions; NSMutableSet *_childExtensionPoints; } @property(readonly, copy) NSSet *childExtensionPoints; // @synthesize childExtensionPoints=_childExtensionPoints; @property(readonly, copy) NSSet *extensions; // @synthesize extensions=_extensions; @property(readonly) DVTPlugIn *plugIn; // @synthesize plugIn=_plugIn; @property(readonly, copy) NSString *name; // @synthesize name=_name; @property(readonly, copy) NSString *version; // @synthesize version=_version; @property(readonly, copy) NSString *identifier; // @synthesize identifier=_identifier; - (void)_registerChildExtensionPoint:(id)arg1; - (void)_registerExtension:(id)arg1; - (id)extensionsMatchingPredicate:(id)arg1; @property(readonly) NSBundle *bundle; @property(readonly) DVTExtensionPoint *parentExtensionPoint; // @dynamic parentExtensionPoint; @property(readonly, copy) DVTExtensionElementDescription *extensionSchema; // @dynamic extensionSchema; - (void)_setUpParentExtensionPoint; @property(readonly, copy) NSString *description; - (void)encodeIntoPropertyList:(id)arg1; - (void)awakeWithPropertyList:(id)arg1; - (id)initWithPropertyList:(id)arg1 owner:(id)arg2; - (id)initWithExtensionPointData:(id)arg1 plugIn:(id)arg2; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end
#ifndef KERBEROS_H #define KERBEROS_H #include <node.h> #include <gssapi/gssapi.h> #include <gssapi/gssapi_generic.h> #include <gssapi/gssapi_krb5.h> #include "nan.h" #include <node_object_wrap.h> #include <v8.h> extern "C" { #include "kerberosgss.h" } using namespace v8; using namespace node; class Kerberos : public Nan::ObjectWrap { public: Kerberos(); ~Kerberos() {}; // Constructor used for creating new Kerberos objects from C++ static Nan::Persistent<FunctionTemplate> constructor_template; // Initialize function for the object static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target); // Method available static NAN_METHOD(AuthGSSClientInit); static NAN_METHOD(AuthGSSClientStep); static NAN_METHOD(AuthGSSClientUnwrap); static NAN_METHOD(AuthGSSClientWrap); static NAN_METHOD(AuthGSSClientClean); static NAN_METHOD(AuthGSSServerInit); static NAN_METHOD(AuthGSSServerClean); static NAN_METHOD(AuthGSSServerStep); private: static NAN_METHOD(New); // Handles the uv calls static void Process(uv_work_t* work_req); // Called after work is done static void After(uv_work_t* work_req); }; #endif
#ifndef TCPSERVER_H #define TCPSERVER_H #include <QDialog> #include <QListWidget> #include <QLabel> #include <QLineEdit> #include <QPushButton> #include <QGridLayout> #include "server.h" class TcpServer : public QDialog { Q_OBJECT public: TcpServer(QWidget *parent = 0,Qt::WindowFlags f=0); ~TcpServer(); private: QListWidget *ContentListWidget; QLabel *PortLabel; QLineEdit *PortLineEdit; QPushButton *CreateBtn; QGridLayout *mainLayout; int port; Server *server; public slots: void slotCreateServer(); void updateServer(QString,int); }; #endif // TCPSERVER_H
// // PersonHeadView.h // IntelligentSwitchPro // // Created by carl on 14-12-22. // Copyright (c) 2014年 Carl. All rights reserved. // #import <UIKit/UIKit.h> @interface PersonHeadView : UIView @property (strong, nonatomic) IBOutlet UIImageView *headerImage; @property (strong, nonatomic) IBOutlet UILabel *nameLabel; -(id)initWithFrame:(CGRect)frame; +(PersonHeadView *)instanceTextView ; @end
#ifndef __CUBE_TCP_CONNECTION_H__ #define __CUBE_TCP_CONNECTION_H__ #include <memory> #include "base/buffer.h" #include "callbacks.h" #include "inet_addr.h" namespace cube { namespace net { class EventLoop; class Eventor; class Socket; class TcpConnection : public std::enable_shared_from_this<TcpConnection> { public: enum ConnState { ConnState_Connecting, ConnState_Connected, ConnState_Disconnected, }; TcpConnection(EventLoop *event_loop, int sockfd, const InetAddr &local_addr, const InetAddr &peer_addr); ~TcpConnection(); // connection callback settor void SetConnectionCallback(const ConnectionCallback &cb) { m_connection_callback = cb; } // close callback settor void SetCloseCallback(const CloseCallback &cb) { m_close_callback = cb; } //void SetWriteCompleteCallback(const WriteCompleteCallback &cb) { m_write_complete_callback = cb; } uint64_t Id() const { return m_conn_id; } const InetAddr &LocalAddr() const { return m_local_addr; } const InetAddr &PeerAddr() const { return m_peer_addr; } // call when connection state become ConnState_Connected void OnConnectionEstablished(); // run callback when the read data's length >= read_bytes void ReadBytes(size_t read_bytes, const ReadCallback &cb); // run callback when the read data contains delimiter void ReadUntil(const std::string &delimiter, const ReadCallback &cb); // run callback when the read data's length >= 1 void ReadAny(const ReadCallback &cb); bool Write(const std::string &str); bool Write(const char *data, size_t len); bool Write(const std::string &str, const WriteCompleteCallback &cb); bool Write(const char *data, size_t len, const WriteCompleteCallback &cb); void Close(); // close the connection void CloseAfter(int64_t delay_ms); bool Closed() const { return m_state == ConnState_Disconnected; } void EnableReading(); void DisableReading(); void EnableWriting(); void DisableWriting(); time_t LastActiveTime() const { return m_last_active_time; } const std::string &ErrMsg() const { return m_err_msg; } ConnState GetState() const { return m_state; } EventLoop *GetEventLoop() { return m_event_loop; } friend class Connector; private: void OnRead(); void HandleEvents(int revents); int HandleConnect(); void HandleRead(); void HandleWrite(); void HandleError(); void HandleClose(); private: // noncopyable TcpConnection(const TcpConnection &) = delete; TcpConnection &operator=(const TcpConnection &) = delete; private: static uint64_t m_next_conn_id; // atomic EventLoop *m_event_loop; const uint64_t m_conn_id; std::unique_ptr<Socket> m_sock; std::unique_ptr<Eventor> m_eventor; InetAddr m_local_addr; InetAddr m_peer_addr; ConnState m_state; ::cube::Buffer m_input_buffer; ::cube::Buffer m_output_buffer; std::string m_read_delimiter; int m_read_bytes; time_t m_last_active_time; // callback when connection state changed ConnectionCallback m_connection_callback; // callback when closed connection CloseCallback m_close_callback; ReadCallback m_read_callback; WriteCompleteCallback m_write_complete_callback; std::string m_err_msg; }; typedef std::shared_ptr<TcpConnection> TcpConnectionPtr; typedef std::weak_ptr<TcpConnection> TcpConnectionWPtr; } } #endif
int IVenFila(char tauler[N][M], char jugador); //en el tauler donat comprova si hi ha 4 peces en FILA del jugador donat int IVenColumna(char tauler[N][M], char jugador); //en el tauler donat comprova si hi ha 4 peces en COLUMNA del jugador donat int IVenDiagonal(char tauler[N][M], char jugador);//en el tauler donat comprova si hi ha 4 peces en DIAGONAL del jugador donat int IVenRatlla(char tauler[N][M], char jugador); //donat un tauler comprova si el jugador donat ha connectat 4 peces (fila, columna o diagonal).
// // UITextInputChangeResultModel.h // CJUIKitDemo // // Created by ciyouzen on 2020/5/15. // Copyright © 2020 dvlproad. All rights reserved. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @interface UITextInputChangeResultModel : NSObject { } @property (nonatomic, copy, readonly) NSString *originReplacementString;/**< 原始的替换文本(未处理空格等之前的) */ @property (nullable, nonatomic, copy) NSString *hopeReplacementString; /**< 希望替换的文本(有时候往中间粘贴太多文本时候,希望只粘贴部分) */ @property (nonatomic, copy) NSString *hopeNewText; /**< 最终希望显示的文本(有时候往中间粘贴太多文本时候,希望保留原本的,而只对粘贴部分截取来粘贴) */ @property (nonatomic, assign) BOOL isDifferentFromSystemDeal; /**< 是否最终得到的字符串不同于系统处理(有时候往中间粘贴太多文本时候,希望只粘贴部分) */ /* * 初始化 * * @param originReplacementString 原始的替换文本(未处理空格等之前的) * * @return 模型 */ - (instancetype)initWithOriginReplacementString:(NSString *)originReplacementString NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE; @end NS_ASSUME_NONNULL_END
#ifndef PEACHY_SCRIPT_H #define PEACHY_SCRIPT_H namespace peachy { class Environment; class ExpressionConsumer; class Log; class Runtime; class Script { public: Script(Log * logger, Environment * environment, Runtime * runtime, ExpressionConsumer * expressionConsumer); ~Script(); void run(); protected: Environment * environment; ExpressionConsumer * expressionConsumer; Log * logger; Runtime * runtime; private: Script(); Script(const Script & script); Script & operator = (const Script & script); }; } #endif
/** * \file 68K/Libraries/TransparencyLib/Prv/TransparencyLib.h * * Transparency Library that couples a Ccp channel and a serial port * * This library can be used to couple data between a Ccp channel and a serial * port. It is meant to be used for diagnostics and tethered mode. Since it is a * library, it can work without being in a certain application. * * \license * * Copyright (c) 2002 Handspring Inc., All Rights Reserved * * \author Arun Mathias * * $Id:$ * *****************************************************************************/ #ifndef __TRANSPARENCY_LIB_INT__H__ #define __TRANSPARENCY_LIB_INT__H__ Err TransLibOpenConnection (UInt16 refNum, CcpChannelType portAChannel, UInt32 portB) SYS_TRAP (transLibTrapOpenConnection); Err TransLibCloseConnection (UInt16 refNum) SYS_TRAP (transLibTrapCloseConnection); #endif
#pragma once #include "oxygine_include.h" #include "core/Renderer.h" namespace oxygine { class STDRenderer : public Renderer { public: STDRenderer(IVideoDriver* driver = 0); /**Sets blend mode. Default value is blend_premultiplied_alpha*/ void draw(const RState* rs, const Color&, const RectF& srcRect, const RectF& destRect) OVERRIDE; void setUberShaderProgram(UberShaderProgramBase* pr); void setBlendMode(blend_mode blend); /**Sets texture. If texture is null White texture would be used.*/ void setTexture(spNativeTexture base, spNativeTexture alpha, bool basePremultiplied = true); //debug utils #ifdef OXYGINE_DEBUG_T2P static void showTexel2PixelErrors(bool show); #endif protected: void preDrawBatch(); void _cleanup(); void _begin(); void _resetSettings(); spNativeTexture _base; spNativeTexture _alpha; blend_mode _blend; UberShaderProgramBase* _uberShader; unsigned int _shaderFlags; }; class PrimitiveRenderer { public: PrimitiveRenderer(STDRenderer* r); void setTexture(spNativeTexture texture); void setBlendMode(blend_mode mode); void draw(const void* data, int size, bvertex_format format, bool worldTransform = false); protected: STDRenderer* _renderer; }; class TextRenderer2 { public: TextRenderer2(STDRenderer*); void draw(const AffineTransform& tr, spNativeTexture texture, unsigned int color, const RectF& src, const RectF& dest); protected: spNativeTexture _texture; STDRenderer* _renderer; }; }
void sampleMisstrend(double *y, double B0, double B1, double B2, double B3, double *x1, double *x2, double *x3, double sig2_e, double *Psi, int Nobs, int Nmiss, int *miss, double *ySample); double thetaLogLikeAR_trend(double theta, double *beta, double *X, double sig2, double *y, int N, int p, double alphaTheta, double betaTheta); double sampThetaAR_trend(double theta, double *beta, double *X, double sig2, double *y, int N, int p, double alphaTheta, double betaTheta, double sdmet); void gibbsTwoSampleAR_trend(double *y, int N, double *X, int p, double rscaleInt, double rscaleSlp, double alphaTheta, double betaTheta, double loInt, double upInt, double loSlp, double upSlp, int iterations, int leftSidedInt, int leftSidedSlp, double sdmet, double *chains, double *postp, double *postdens, int progress, int *miss, int Nmiss, SEXP pBar, SEXP rho); SEXP RgibbsTwoSampleAR_trend(SEXP yR, SEXP NR, SEXP XR, SEXP pR, SEXP rscaleIntR, SEXP rscaleSlpR, SEXP alphaThetaR, SEXP betaThetaR, SEXP loIntR, SEXP upIntR, SEXP loSlpR, SEXP upSlpR, SEXP iterationsR, SEXP leftSidedIntR, SEXP leftSidedSlpR, SEXP sdmetR, SEXP missR, SEXP NmissR, SEXP progressR, SEXP pBar, SEXP rho); SEXP MCAR_trend(SEXP yR, SEXP NR, SEXP NmissR, SEXP distMatR, SEXP alphaThetaR, SEXP betaThetaR, SEXP rsqIntR, SEXP rsqSlpR, SEXP X0R, SEXP X1R, SEXP iterationsR, SEXP progressR, SEXP pBar, SEXP rho); void MCmargLogLikeAR_trend(double theta, int Nmiss, int *distMat, double g1, double g2, double *y, int N, double alphaTheta, double betaTheta, double rsqInt, double rsqSlp, double *X0, double *X1, double *like); SEXP MCmargLogLikeAR_trendR(SEXP thetaR, SEXP NmissR, SEXP distMatR, SEXP g1R, SEXP g2R, SEXP yR, SEXP NR, SEXP alphaThetaR, SEXP betaThetaR, SEXP rsqIntR, SEXP rsqSlpR, SEXP X0R, SEXP X1R); SEXP MCnullMargLogLikeAR_trend(SEXP thetaR, SEXP NmissR, SEXP distMatR, SEXP yR, SEXP NR, SEXP alphaThetaR, SEXP betaThetaR, SEXP X0R); void quadformMatrix(double *X, double *S, int N, int p, double *Ans, double coeff, int invert);
// copyright 2016 john howard (orthopteroid@gmail.com) // MIT license #ifndef PSYCHICSNIFFLE_HYDRO_MATH_H #define PSYCHICSNIFFLE_HYDRO_MATH_H #include <sys/types.h> #include <cmath> namespace hydro { using namespace std; struct StatPosNeg { float pos, neg; StatPosNeg() : pos(0), neg(0) {} inline void clear() { pos=neg=0.; } inline void inc( float v ) { if( v > 0 ) pos+=v; else neg+=-v; } inline void incGT( float v, const float tol = .01f ) { if( v > 0 ) pos+=(v>tol?v:0.f); else neg+=(v<tol?-v:0); } }; struct StatMinMax { float min, max; StatMinMax() : min(HUGE_VALF), max(-HUGE_VALF) {} inline void clear() { min=HUGE_VALF; max=-HUGE_VALF; } inline void inc( float v ) { {if(v<min)min=v;} {if(v>max)max=v;} } inline float maximum() { return fabs(max) > fabs(min) ? max : min; } }; struct StatStdDev { float tot; uint num; StatStdDev() : tot(0), num(0) {} inline void clear() { tot=0.; num=0; } inline void inc( float v ) { tot += sqrt( v * v ); num++; } inline void incNZ( float v, const float tol = .01f ) { if( fabs( v ) > tol ) { inc( v ); } } inline float stdev() { return num == 0 ? 0 : tot / num; } }; struct StatAvg { float tot; uint num; StatAvg() : tot(0), num(0) {} inline void clear() { tot=0.; num=0; } inline void inc( float v ) { tot += v; num++; } inline void incGZ( float v, const float tol = .01f ) { if( v > tol ) { inc( v ); } } inline float avg() { return num == 0 ? 0 : tot / num; } }; inline void Clamp(float &v, const float min, const float max) { if( v< min ) v = min; else if( v > max ) v = max; } inline float CalcQ(float p, float e, float h, float units) { return p / ((e / 100.f) * h * units); } inline float CalcE(float p, float q, float h, float units) { return q < .1 ? 0.f : 100.f * p / (q * h * units); } // https://www.e-education.psu.edu/natureofgeoinfo/c7_p9.html // uses inverse distce weighting float CalcInterpolate( const float *chart, float Qp, float Qh ); // http://geomalgorithms.com/a03-_inclusion.html bool CalcContains( const float* poly, float Qp, float Qh ); // for the given polygon and x,y value return the min x (left edge) and delta x (span) at the y value. // the purpose of this alg is to provide an x-span that can be discreteized by the number of FRACBITS in a UnitOp. // (the x value is not necessary to pass in as an arg as it is encoded as the first value of the poly) // it may be possible to improve the alg to avoid the use of an x value at all. void CalcSpan( float& min, float& span, float* poly, float head ); } #endif //PSYCHICSNIFFLE_HYDRO_MATH_H
// Copyright 2016-2019 Vladimir Alyamkin. All Rights Reserved. #pragma once #include "VtaTextureAtlasImportFactory.h" #include "EditorReimportHandler.h" #include "VtaTextureAtlasReimportFactory.generated.h" /** * Reimports a UVtaTextureAtlas asset */ UCLASS() class VATEXATLASEDITORPLUGIN_API UVtaTextureAtlasReimportFactory : public UVtaTextureAtlasImportFactory, public FReimportHandler { GENERATED_UCLASS_BODY() //~ Begin FReimportHandler Interface virtual bool CanReimport(UObject* Obj, TArray<FString>& OutFilenames) override; virtual void SetReimportPaths(UObject* Obj, const TArray<FString>& NewReimportPaths) override; virtual EReimportResult::Type Reimport(UObject* Obj) override; virtual int32 GetPriority() const override; //~ End FReimportHandler Interface };
/* * Generated by class-dump 3.3.4 (64 bit). * * class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2011 by Steve Nygard. */ #import "NSObject.h" @interface ABRecordMerger : NSObject { } + (void)mergeVCardRecord:(void *)arg1 withProperties:(struct __CFArray *)arg2 intoRecord:(void *)arg3; + (_Bool)_propertiesArray:(id)arg1 containsProperty:(int)arg2; + (_Bool)mergeMultiValueProperty:(int)arg1 fromRecord:(void *)arg2 intoRecord:(void *)arg3; + (_Bool)_addMultiValueEntry:(void *)arg1 atIndex:(long long)arg2 toMultiValue:(void *)arg3 withProperty:(int)arg4 existingValues:(struct __CFSet *)arg5; + (void)_addValue:(void *)arg1 withProperty:(int)arg2 toExistingValues:(struct __CFSet *)arg3; + (_Bool)_mergeSingleValueProperty:(int)arg1 fromRecord:(void *)arg2 intoRecord:(void *)arg3; @end
/* LV (Length-Value) data encoding */ #ifndef __LV_FORMAT_H__ #define __LV_FORMAT_H__ #include <sys/compiler.h> #include <mem/unaligned.h> /* Run block on fixed size string */ #define VISIT_LV_STR_U8(payload, avail, lv, block) /* Run block on fixed size string in native order */ #define VISIT_LV_STR_U16(payload, avail, lv, block) /* Run block on fixed size string in big endian order */ #define VISIT_LV_STR_BE16(payload, avail, lv, block) \ /* Run block on fixed size string in little endian order */ #define VISIT_LV_STR_LE16(payload, avail, lv, block) \ /* Run block on fixed size string in native order */ #define VISIT_LV_STR_U32(payload, avail, lv, block) /* Run block on fixed size string in big endian order */ #define VISIT_LV_STR_BE32(payload, avail, lv, block) \ /* Run block on fixed size string in little endian order */ #define VISIT_LV_STR_LE32(payload, avail, lv, block) \ /* Run block on fixed size string in native order */ #define VISIT_LV_STR_U64(payload, avail, lv, block) /* Run block on fixed size string in big endian order */ #define VISIT_LV_STR_BE64(payload, avail, lv, block) \ /* Run block on fixed size string in little endian order */ #define VISIT_LV_STR_LE64(payload, avail, lv, block) \ /* Run block on fixed size buffer */ #define VISIT_LV_BUF_U8(payload, avail, lv, block) /* Run block on fixed size buffer in native order */ #define VISIT_LV_BUF_U16(payload, avail, lv, block) /* Run block on fixed size buffer in big endian order */ #define VISIT_LV_BUF_BE16(lv, avail, ptr, len, block) \ { \ u16 len = be16_cpu(*((be16*)lv)); u8 *ptr = (((u8*)lv) + 2); \ CHECK_AVAIL(len, avail, -1); \ if (len > 0) { \ block \ } \ } /* Run block on fixed size buffer in little endian order */ #define VISIT_LV_BUF_LE16(payload, avail, lv, block) \ /* Run block on fixed size buffer in native order */ #define VISIT_LV_BUF_U32(payload, avail, lv, block) /* Run block on fixed size buffer in big endian order */ #define VISIT_LV_BUF_BE32(payload, avail, lv, block) \ /* Run block on fixed size buffer in little endian order */ #define VISIT_LV_BUF_LE32(payload, avail, lv, block) \ /* Run block on fixed size buffer in native order */ #define VISIT_LV_BUF_U64(payload, avail, lv, block) /* Run block on fixed size buffer in big endian order */ #define VISIT_LV_BUF_BE64(payload, avail, lv, block) \ /* Run block on fixed size buffer in little endian order */ #define VISIT_LV_BUF_LE64(payload, avail, lv, block) \ #define VISIT_AVAIL(avail, size, block) if (size <= avail) { block } #define CHECK_AVAIL(size, avail, error) if (size > avail) { return error; } #define MOVE_PAYLOAD(payload, avail, size) \ payload = (__typeof__(payload))(((u8*)payload) + size); avail -= size; \ #define VISIT_STRUCT(payload, avail, type, val, block) \ { \ type val = (type)payload; \ CHECK_AVAIL(sizeof(*val), avail, -1); \ MOVE_PAYLOAD(payload, avail, sizeof(*val)); \ block \ } #define VISIT_MAYBE_STRUCT(payload, avail, type, val, block) \ { \ type val = (type)payload; \ VISIT_AVAIL(avail, sizeof(*val), { \ MOVE_PAYLOAD(payload, avail, sizeof(*val)); \ block \ }); \ } #define VISIT_LV_BUF_BE24(lv, avail, ptr, size, block) \ { \ u32 size = be24_cpu(((u8*)lv)); \ u8 *ptr = (((u8*)lv) + 3); \ CHECK_AVAIL(size, avail, -1); \ if (size > 0) { \ block \ } \ } #define REQUIRE_BE16(payload, val) \ if (be16_cpu(*((be16*)payload)) != val) return -EPROTO #define READ_BE16(lv, avail, ptr, size) \ CHECK_AVAIL(size, avail, -1); \ *((be16*)ptr) = be16_cpu(*((be16*)lv)); \ MOVE_PAYLOAD(payload, avail, size) #define READ_B16_REQUIRE(lv, avail, ptr, size, expected) \ READ_BE16(lv, avail, ptr, size); \ REQUIRE_BE16(ptr, expected) #define READ_BUF(lv, avail, ptr, size) \ CHECK_AVAIL(size, avail, -1); \ memcpy(ptr, lv, size); \ MOVE_PAYLOAD(payload, avail, size) #define READ_LV_BUF_BE16(lv, avail, ptr, size, maxsize) \ CHECK_AVAIL(size, avail, -1); \ size = be16_cpu(*((be16*)lv)); \ CHECK_AVAIL(size, avail, -1); \ CHECK_LV_SIZE_LIMIT(size, maxsize); \ if (size > 0) { \ memcpy(ptr, (((u8*)lv) + 2), size); \ MOVE_PAYLOAD(payload, avail, size); \ } \ #define SKIP_LV_BUF_BE16(lv, avail) \ { \ CHECK_AVAIL(2, avail, -1); \ u16 size_not_used = be16_cpu(*((be16*)lv)); \ MOVE_PAYLOAD(lv, avail, 2);\ CHECK_AVAIL(size_not_used, avail, -1); \ if (size_not_used > 0) { \ MOVE_PAYLOAD(lv, avail, size_not_used); \ } \ } \ #define GET_LV_BUF_BE16(lv, avail, ptr, size) \ CHECK_AVAIL(2, avail, -1); \ size = be16_cpu(*((be16*)lv)); \ CHECK_AVAIL(size, avail, -1); \ MOVE_PAYLOAD(lv, avail, 2);\ if (size > 0) { \ ptr = (((u8*)lv)); \ MOVE_PAYLOAD(lv, avail, size); \ debug4("get_lv_buf_be16 (payload: %p, size: %d avail: %d", lv, size, avail); \ } \ #define GET_LV_BUF_BE32(lv, avail, ptr, size) \ CHECK_AVAIL(4, avail, -1); \ size = be32_cpu(*((be16*)lv)); \ CHECK_AVAIL(size, avail, -1); \ MOVE_PAYLOAD(lv, avail, 4);\ if (size > 0) { \ ptr = (((u8*)lv)); \ MOVE_PAYLOAD(lv, avail, size); \ } \ #define CHECK_LV_SIZE_LIMIT(size, limit) \ if (size > limit) return -EPROTO #endif
#include <stdlib.h> #include <stdio.h> #include <inttypes.h> #include <stdarg.h> #include <ctype.h> #include <string.h> #include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include "util.h" /* Some systems don't have strndup. */ char * strdupn(char *s, size_t len) { char *ret; ret = xalloc(len + 1); memcpy(ret, s, len); ret[len] = '\0'; return ret; } char * xstrdup(char *s) { char *p; p = strdup(s); if (!p && s) die("Out of memory"); return p; } char * strjoin(char *u, char *v) { size_t n; char *s; n = strlen(u) + strlen(v) + 1; s = xalloc(n); bprintf(s, n + 1, "%s%s", u, v); return s; } char * swapsuffix(char *buf, size_t sz, char *s, char *suf, char *swap) { size_t slen, suflen, swaplen; slen = strlen(s); suflen = strlen(suf); swaplen = strlen(swap); if (slen < suflen) return NULL; if (slen + swaplen >= sz) die("swapsuffix: buf too small"); buf[0] = '\0'; /* if we have matching suffixes */ if (suflen < slen && !strcmp(suf, &s[slen - suflen])) { strncat(buf, s, slen - suflen); strncat(buf, swap, swaplen); } else { bprintf(buf, sz, "%s%s", s, swap); } return buf; } size_t max(size_t a, size_t b) { if (a > b) return a; else return b; } size_t min(size_t a, size_t b) { if (a < b) return a; else return b; } size_t align(size_t sz, size_t a) { /* align to 0 just returns sz */ if (a == 0) return sz; return (sz + a - 1) & ~(a - 1); } void indentf(int depth, char *fmt, ...) { va_list ap; va_start(ap, fmt); vfindentf(stdout, depth, fmt, ap); va_end(ap); } void findentf(FILE *fd, int depth, char *fmt, ...) { va_list ap; va_start(ap, fmt); vfindentf(fd, depth, fmt, ap); va_end(ap); } void vfindentf(FILE *fd, int depth, char *fmt, va_list ap) { ssize_t i; for (i = 0; i < depth; i++) fprintf(fd, "\t"); vfprintf(fd, fmt, ap); } static int optinfo(Optctx *ctx, char arg, int *take, int *mand) { char *s; for (s = ctx->optstr; *s != '\0'; s++) { if (*s == arg) { s++; if (*s == ':') { *take = 1; *mand = 1; return 1; } else if (*s == '?') { *take = 1; *mand = 0; return 1; } else { *take = 0; *mand = 0; return 1; } } } return 0; } static int findnextopt(Optctx *ctx) { size_t i; for (i = ctx->argidx + 1; i < ctx->noptargs; i++) { if (ctx->optargs[i][0] == '-') goto foundopt; else lappend(&ctx->args, &ctx->nargs, ctx->optargs[i]); } ctx->finished = 1; return 0; foundopt : ctx->argidx = i; ctx->curarg = ctx->optargs[i] + 1; /* skip initial '-' */ return 1; } void optinit(Optctx *ctx, char *optstr, char **optargs, size_t noptargs) { ctx->args = NULL; ctx->nargs = 0; ctx->optstr = optstr; ctx->optargs = optargs; ctx->noptargs = noptargs; ctx->optdone = 0; ctx->finished = 0; ctx->argidx = 0; ctx->curarg = ""; findnextopt(ctx); } int optnext(Optctx *ctx) { int take, mand; int c; c = *ctx->curarg; ctx->curarg++; if (!optinfo(ctx, c, &take, &mand)) { printf("Unexpected argument %c\n", c); exit(1); } ctx->optarg = NULL; if (take) { if (*ctx->curarg) { ctx->optarg = ctx->curarg; ctx->curarg += strlen(ctx->optarg); } else if (ctx->argidx < ctx->noptargs - 1) { ctx->optarg = ctx->optargs[ctx->argidx + 1]; ctx->argidx++; } else if (mand) { fprintf(stderr, "expected argument for %c\n", *ctx->curarg); } findnextopt(ctx); } else { if (*ctx->curarg == '\0') findnextopt(ctx); } return c; } int optdone(Optctx *ctx) { return *ctx->curarg == '\0' && ctx->finished; }
#ifndef classes_h #define classes_h // Basic classes class Point { public: double x; double y; }; #endif // classes_h
#pragma once #include <d3dx9.h> #include <string> #include <memory> #include <unordered_map> #include "Point.h" struct TextureUV { float tu1, tv1, tu2, tv2; }; class Texture { public: Texture(LPDIRECT3DDEVICE9 d3dDevice, const std::string& filePath) : m_d3dDevice(d3dDevice), m_tex(), m_size(0, 0) { HRESULT hr = D3DXCreateTextureFromFile(m_d3dDevice, TEXT(filePath.c_str()), &m_tex); if (FAILED(hr)) throw std::runtime_error("Failed load " + filePath); //‰æ‘œ‚̃TƒCƒY‚ðŽæ“¾ D3DXIMAGE_INFO info; D3DXGetImageInfoFromFile(filePath.c_str(), &info); m_size.x = info.Width; m_size.y = info.Height; } ~Texture() { if (m_tex) m_tex->Release(); } LPDIRECT3DTEXTURE9 const getTexPtr() const { return m_tex; } Point getSize() const { return m_size; } private: LPDIRECT3DDEVICE9 m_d3dDevice; LPDIRECT3DTEXTURE9 m_tex; Point m_size; }; using TexturePtr = std::shared_ptr<Texture>; class TextureManager { public: TextureManager(LPDIRECT3DDEVICE9 d3dDevice) : m_d3dDevice(d3dDevice) {} void load(const std::string& filePath, const std::string& alias) { m_textures[alias] = std::make_shared<Texture>(m_d3dDevice, filePath); } void clear() { m_textures.clear(); } std::shared_ptr<Texture> get(const std::string& alias) { if (m_textures.count(alias) == 0) throw std::out_of_range("Not Found " + alias); return m_textures[alias]; } private: std::unordered_map<std::string, std::shared_ptr<Texture>> m_textures; LPDIRECT3DDEVICE9 m_d3dDevice; }; using TextureManagerPtr = std::shared_ptr<TextureManager>;
// // AppDelegate.h // ViewControllerDelegate // // Created by Diogo Tridapalli on 10/15/15. // Copyright © 2015 Diogo Tridapalli. All rights reserved. // #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
// // SPQuad.h // Sparrow // // Created by Daniel Sperl on 15.03.09. // Copyright 2011-2014 Gamua. All rights reserved. // // This program is free software; you can redistribute it and/or modify // it under the terms of the Simplified BSD License. // #import <Foundation/Foundation.h> #import <Sparrow/SPDisplayObject.h> @class SPTexture; @class SPVertexData; /** ------------------------------------------------------------------------------------------------ An SPQuad represents a rectangle with a uniform color or a color gradient. You can set one color per vertex. The colors will smoothly fade into each other over the area of the quad. To display a simple linear color gradient, assign one color to vertices 0 and 1 and another color to vertices 2 and 3. The indices of the vertices are arranged like this: 0 - 1 | / | 2 - 3 **Colors** Colors in Sparrow are defined as unsigned integers, that's exactly 8 bit per color. The easiest way to define a color is by writing it as a hexadecimal number. A color has the following structure: 0xRRGGBB That means that you can create the base colors like this: 0xFF0000 -> red 0x00FF00 -> green 0x0000FF -> blue Other simple colors: 0x000000 or 0x0 -> black 0xFFFFFF -> white 0x808080 -> 50% gray If you're not comfortable with that, there is also a utility macro available that takes the values for R, G and B separately: uint red = SP_COLOR(255, 0, 0); ------------------------------------------------------------------------------------------------- */ @interface SPQuad : SPDisplayObject { SPVertexData *_vertexData; } /// -------------------- /// @name Initialization /// -------------------- /// Initializes a quad with a certain size and color. The `pma` parameter indicates how the colors /// of the object are stored. _Designated Initializer_. - (instancetype)initWithWidth:(float)width height:(float)height color:(uint)color premultipliedAlpha:(BOOL)pma; /// Initializes a quad with a certain size and color, using premultiplied alpha values. - (instancetype)initWithWidth:(float)width height:(float)height color:(uint)color; /// Initializes a white quad with a certain size. - (instancetype)initWithWidth:(float)width height:(float)height; /// Factory method. + (instancetype)quadWithWidth:(float)width height:(float)height; /// Factory method. + (instancetype)quadWithWidth:(float)width height:(float)height color:(uint)color; /// Factory method. Creates a 32x32 quad. + (instancetype)quad; /// ------------- /// @name Methods /// ------------- /// Sets the color of a vertex. - (void)setColor:(uint)color ofVertex:(int)vertexID; /// Returns the color of a vertex. - (uint)colorOfVertex:(int)vertexID; /// Sets the alpha value of a vertex. - (void)setAlpha:(float)alpha ofVertex:(int)vertexID; /// Returns the alpha value of a vertex. - (float)alphaOfVertex:(int)vertexID; /// Copies the raw vertex data to a VertexData instance. - (void)copyVertexDataTo:(SPVertexData *)targetData atIndex:(int)targetIndex; /// Call this method after manually changing the contents of '_vertexData'. - (void)vertexDataDidChange; /// ---------------- /// @name Properties /// ---------------- /// Sets the colors of all vertices simultaneously. Returns the color of vertex '0'. @property (nonatomic, assign) uint color; /// Indicates if the rgb values are stored premultiplied with the alpha value. This can have /// effect on the rendering. (Most developers don't have to care, though.) @property (nonatomic, assign) BOOL premultipliedAlpha; /// Indicates if any vertices have a non-white color or are not fully opaque. Any alpha value /// other than '1' will also cause tinting. @property (nonatomic, readonly) BOOL tinted; /// The texture that is displayed on the quad. For pure quads (no subclasses), this is always nil. @property (nonatomic, readonly) SPTexture *texture; @end
#ifndef OPENTISSUE_UTILITY_UTILITY_TAG_TRAITS_H #define OPENTISSUE_UTILITY_UTILITY_TAG_TRAITS_H // // OpenTissue Template Library // - A generic toolbox for physics-based modeling and simulation. // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. // // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php // #include <boost/utility.hpp> namespace OpenTissue { namespace utility { /** Tagging mechanism using SFINAE (substitution-failure-is-not-an-error) principle. Example of two classes, one without tags, other with tag member. Note that to provide support for the tag, one needs to add the typedef *and* the m_tag member variable. Optimized compilers should not generate code for if(has_tag(T)) conditionals where T doesn't support tags. struct bar {}; struct foo { typedef void has_tag; int m_tag; foo() : m_tag(23) {} }; struct blah : public TagSupportedType<int> {}; int main() { bar a; foo b; std::cout << "bar has tag: " << has_tag(a) << std::endl; std::cout << "foo has tag: " << has_tag(b) << std::endl; if (has_tag(a)) return 1; // always 0 std::cout << "bar's tag value is " << tag_value(a) << std::endl; if (tag_value(b)) return 1; std::cout << "foo's tag value is " << tag_value(b) << std::endl; return 0; } */ template <typename T> struct TagSupportedType { typedef void has_tag; ///< Dummy typedef, required for SFINAE typedef T tag_type; ///< The type of the tag value tag_type m_tag; ///< The tag value }; typedef TagSupportedType<int> default_tag_supported_type; template <class T, class Enable = void> struct tag_traits { static bool const has_tag = false; typedef int tag_type; }; template <class T> struct tag_traits<T, typename T::has_tag > { static bool const has_tag = true; typedef typename T::tag_type tag_type; }; template <class T> inline bool has_tag(T const & obj, typename boost::disable_if_c< tag_traits<T>::has_tag >::type * dummy = 0) { return false; } template <class T> inline bool has_tag(T const & obj, typename boost::enable_if_c< tag_traits<T>::has_tag >::type * dummy = 0) { return true; } template <typename T> inline typename tag_traits<T>::tag_type tag_value(T const & obj, typename boost::disable_if_c< tag_traits<T>::has_tag >::type * dummy = 0) { return 0; } template <typename T> inline typename tag_traits<T>::tag_type tag_value(T const & obj, typename boost::enable_if_c< tag_traits<T>::has_tag >::type * dummy = 0) { return obj.m_tag; } template <class T> inline void set_tag(T & /* obj */, typename tag_traits<T>::tag_type const & /* tag */, typename boost::disable_if_c< tag_traits<T>::has_tag >::type * dummy = 0) { } template <class T> inline void set_tag(T & obj, typename tag_traits<T>::tag_type const & tag, typename boost::enable_if_c< tag_traits<T>::has_tag >::type * dummy = 0) { obj.m_tag = tag; } } //namespace utility } //namespace OpenTissue // OPENTISSUE_UTILITY_UTILITY_TAG_TRAITS_H #endif
/********************************************************/ /* */ /* Copley Motion Libraries */ /* */ /* Copyright (c) 2002 Copley Controls Corp. */ /* http://www.copleycontrols.com */ /* */ /********************************************************/ /** \file CAN hardware interface for the Ixxat CAN driver */ #ifndef _DEF_INC_CAN_IXXAT_V3 #define _DEF_INC_CAN_IXXAT_V3 #include "CML_Settings.h" #include "CML_can.h" #include "CML_Threads.h" CML_NAMESPACE_START(); /// This gives the size of the CAN message receive queue /// used for Ixxat cards #define IXXAT_RX_QUEUE_SZ 50 /** Ixxat specific CAN interface. This class extends the generic CanInterface class into a working interface for the Ixxat can device driver. */ class IxxatCANV3 : public CanInterface { public: IxxatCANV3( void ); IxxatCANV3( const char *port ); virtual ~IxxatCANV3( void ); const Error *Open( void ); const Error *Close( void ); const Error *SetBaud( int32 baud ); void rxInt( int16 ct, void *frame ); protected: const Error *RecvFrame( CanFrame &frame, Timeout timeout ); const Error *XmitFrame( CanFrame &frame, Timeout timeout ); /// tracks the state of the interface as open or closed. int open; /// Which CAN channel to use (on multi-channel boards). /// For the moment this is always set to zero. uint8 channel; /// Holds a copy of the last baud rate set int32 baud; uint8 CAN_BT0, CAN_BT1; /// File handle used to access the CAN channel int handle; uint16 txQueue; uint16 rxQueue; const Error *ConvertError( int err ); Mutex mutex; }; CML_NAMESPACE_END(); #endif
/************************************************************ * Student Name: TreeBots * * Exercise Name: Ex6 * * File description: Declaration of Vector Class * ***********************************************************/ #ifndef __Robocup__MidFielderA__ #define __Robocup__MidFielderA__ #include "Player.h" /********************************************************************************** * MidFielder Class: Represents a player that plays like a MidFielder. * * It deals with the information recieved from the states * * by sending instructions. * *********************************************************************************/ class MidFielderA : public Player { private: void actPlayMode(PlayMode ePlayMode); public: // --- PUBLIC FUNCTIONS --- // /************************************************************************************************ * function name: MidFielder Constructor * * The Input: const Connection object (pointer), const char (pointer), const Vector (reference) * * The output: none * * The Function Opertion: Initializes the object with input client connection, * * team name and position. * * *********************************************************************************************/ MidFielderA(const Connection* cConnection, const char* chTeamName); /********************************************************************************************** * function name: MidFielder Destructor * * The Input: none * * The output: none * * The Function Opertion: Destroys the current object. * * *******************************************************************************************/ ~MidFielderA(); }; #endif
/* Implemente um Programa em C, que leia a quantidade de pessoas hospedadas em uma Pousada, bem como o tempo (em dias) que eles ficarão na Pousada. O algoritmo deve calcular e escrever o valor total a pagar considerando que a diária por pessoa é de R$ 234,00 e que é cobrado também por pessoa uma taxa de serviço de 5% do valor total. */ #include <stdio.h> #include <stdlib.h> main() { int pessoas, tempo; float valorTotal; printf("Digite a quantidade de pessas hospedadas: "); scanf("%i", &pessoas); printf("Digite o tempo em que ficarao hospedadas: "); scanf("%i", &tempo); valorTotal = pessoas * (tempo * 234); valorTotal += valorTotal * 0.05; printf("Valor total a ser pago: %.2f\n", valorTotal); system("pause"); }
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. // Modified by SAPCoin developers - 2016 #ifndef BITCOIN_TXDB_LEVELDB_H #define BITCOIN_TXDB_LEVELDB_H #include "main.h" #include "leveldb.h" /** CCoinsView backed by the LevelDB coin database (chainstate/) */ class CCoinsViewDB : public CCoinsView { protected: CLevelDB db; public: CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); bool GetCoins(const uint256 &txid, CCoins &coins); bool SetCoins(const uint256 &txid, const CCoins &coins); bool HaveCoins(const uint256 &txid); CBlockIndex *GetBestBlock(); bool SetBestBlock(CBlockIndex *pindex); bool BatchWrite(const std::map<uint256, CCoins> &mapCoins, CBlockIndex *pindex); bool GetStats(CCoinsStats &stats); }; /** Access to the block database (blocks/index/) */ class CBlockTreeDB : public CLevelDB { public: CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); private: CBlockTreeDB(const CBlockTreeDB&); void operator=(const CBlockTreeDB&); public: bool WriteBlockIndex(const CDiskBlockIndex& blockindex); bool ReadBestInvalidWork(CBigNum& bnBestInvalidWork); bool WriteBestInvalidWork(const CBigNum& bnBestInvalidWork); bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo); bool WriteBlockFileInfo(int nFile, const CBlockFileInfo &fileinfo); bool ReadLastBlockFile(int &nFile); bool WriteLastBlockFile(int nFile); bool WriteReindexing(bool fReindex); bool ReadReindexing(bool &fReindex); bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos); bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list); bool WriteFlag(const std::string &name, bool fValue); bool ReadFlag(const std::string &name, bool &fValue); bool LoadBlockIndexGuts(); }; #endif // BITCOIN_TXDB_LEVELDB_H
/** * @file external.h * @brief existence and compatibility checks for external tools * * Copyright (C) 2009 Gummi Developers * All Rights reserved. * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __GUMMI_EXTERNAL_H__ #define __GUMMI_EXTERNAL_H__ #include <glib.h> typedef struct { gboolean exists; gchar* version; } External; typedef enum _ExternalProg { EX_TEXLIVE = 0, EX_LATEX, EX_PDFLATEX, EX_XELATEX, EX_RUBBER, EX_LATEXMK, EX_TEXCOUNT } ExternalProg; gboolean external_exists (const gchar* program); gboolean external_hasflag (const gchar* program, const gchar* flag); gchar* external_version (const gchar* program); gdouble external_version2 (ExternalProg program); #endif /* __GUMMI_EXTERNAL_H__ */
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "CDStructures.h" @class DVTStackBacktrace, NSArray, NSMutableArray, NSString; @interface DVTSourceLandmarkItem : NSObject { DVTSourceLandmarkItem *_parent; NSMutableArray *_children; NSString *_name; int _type; struct _NSRange _range; struct _NSRange _nameRange; NSString *_typeName; long long _nestingLevel; long long _indentLevel; double _timestamp; DVTStackBacktrace *_pendingUpdateBacktrace; id _delegate; void *_itemRef; } + (int)sourceLandmarkItemTypeForNodeType:(long long)arg1; @property long long indentLevel; // @synthesize indentLevel=_indentLevel; @property long long nestingLevel; // @synthesize nestingLevel=_nestingLevel; @property(readonly) double timestamp; // @synthesize timestamp=_timestamp; @property(nonatomic) struct _NSRange nameRange; // @synthesize nameRange=_nameRange; @property(nonatomic) struct _NSRange range; // @synthesize range=_range; @property(readonly) int type; // @synthesize type=_type; @property(copy, nonatomic) NSString *name; // @synthesize name=_name; @property DVTSourceLandmarkItem *parent; // @synthesize parent=_parent; @property(readonly) BOOL needsUpdate; - (void)markForUpdate; - (long long)compareWithLandmarkItem:(id)arg1; - (BOOL)isDeclaration; - (void)removeChildAtIndex:(long long)arg1; - (void)insertChild:(id)arg1 atIndex:(long long)arg2; - (void)removeObjectFromChildrenAtIndex:(unsigned long long)arg1; - (void)insertObject:(id)arg1 inChildrenAtIndex:(unsigned long long)arg2; @property(readonly) long long numberOfChildren; @property(readonly) NSMutableArray *_children; @property(readonly) NSArray *children; - (BOOL)isEqual:(id)arg1; - (unsigned long long)hash; - (id)description; @property(readonly, copy, nonatomic) NSString *typeName; // @synthesize typeName=_typeName; - (void)_evaluateTypeName; - (void)_evaluateNameAndRange; - (void)dealloc; - (id)initWithItem:(id)arg1 type:(int)arg2 delegate:(id)arg3; - (id)initWithItemReference:(void *)arg1 type:(int)arg2 delegate:(id)arg3; - (id)initWithName:(id)arg1 type:(int)arg2; @end
#include <stdio.h> /* 1 set b 99 2 set c b b = 99 c = b if part2: goto 5 3 jnz a !5 4 jnz 1 !9 5 mul b 100 6 sub b -100000 b = 99*100 + 100000 = 109900 7 set c b 8 sub c -17000 c = 126900, TOP: 9 set f 1 10 set d 2 OUTER: 11 set e 2 INNER: 12 set g d 13 mul g e 14 sub g b if d*e == b: f = 0 15 jnz g !17 16 set f 0 e += 1 17 sub e -1 g = e - b 18 set g e 19 sub g b if e != b goto INNER 20 jnz g !INNER d += 1 21 sub d -1 if d != b: goto OUTER 22 set g d 23 sub g b 24 jnz g OUTER if f == 0: h += 1 25 jnz f !27 26 sub h -1 if b == c: EXIT 27 set g b 28 sub g c 29 jnz g !31 30 jnz 1 EXIT b += 17 goto TOP 31 sub b -17 32 jnz 1 TOP */ void func(long a) { long b, c, d, e, f, g, h; b = c = d = e = f = g = h = 0; long cnt = 0; b = 99; c = b; if (a) { cnt++; b = b*100 + 100000; /* 109900 */ c = b + 17000; /* 126900 */ } for (;;) { f = 1; d = 2; do { cnt += (b - 2); if (b % d == 0) f = 0; e = b; d++; //} while (d != b); // I didn't have this optimization in my original solve but it cuts // running time from ~1s to ~15ms. // For my original solution I really just analzyed the absolute // innermost loop, replaced it with a mod } while (d*d < b); if (f == 0) { h++; } if (b == c) { printf("cnt: %ld\n", cnt); printf("h: %ld\n", h); return ; } b += 17; } } int main() { func(0); func(1); }
// // BIBeaconSignal.h // BEACONinsideSDK // // Copyright (c) 2014 BEACONinside. All rights reserved. // @import Foundation; @import CoreLocation; #import "BITypes.h" /** * Encapsulates the properties of a signal received by an iBeacon. */ @interface BIBeaconSignal : NSObject - (instancetype)initWithTimestamp:(NSDate *)timestamp RSSI:(NSInteger)rssi proximity:(CLProximity)proximity accuracy:(CLLocationAccuracy)accuracy NS_DESIGNATED_INITIALIZER; - (instancetype)initWithTimestamp:(NSDate *)timestamp coreLocationBeacon:(CLBeacon *)beacon; - (instancetype)initWithTimestamp:(NSDate *)timestamp otherBeaconSignal:(BIBeaconSignal *)otherBeaconSignal; + (instancetype)notInRangeSignalWithTimestamp:(NSDate *)timestamp; @property (nonatomic, strong, readonly) NSDate *timestamp; @property (nonatomic, readonly) BOOL inRange; @property (nonatomic, readonly) NSInteger RSSI; @property (nonatomic, readonly) CLProximity proximity; @property (nonatomic, readonly) CLLocationAccuracy accuracy; @end
#pragma once #include "engine.core/sys.h" #include "core.h" #include <memory> namespace render { class device; } namespace ui { class view; class controller; class element { public: element() : m_view(nullptr) , m_controller(nullptr) { } virtual ~element() { m_view = nullptr; m_controller = nullptr; m_core = nullptr; } virtual void Create(std::shared_ptr<core_ui> core); virtual void Update(float deltaTime); virtual void Draw(); std::shared_ptr<core_ui> GetCore() const { return m_core; } protected: std::unique_ptr<view> m_view; std::unique_ptr<controller> m_controller; std::shared_ptr<core_ui> m_core; }; class view { public: view(element& element) : m_element(element) { } virtual ~view() {} virtual void Create() { } virtual void Update(float deltaTime) { UNREFERENCED(deltaTime); } virtual void Draw() { } protected: element& m_element; private: view& operator = (const view&) = delete; view(const view&) = delete; view(const view&&) = delete; }; class controller { public: controller(element& element) : m_element(element) { } virtual void Create() { } virtual bool HandleInput(float deltaTime, const input::input_state& inputState) { UNREFERENCED(deltaTime); UNREFERENCED(inputState); return false; } virtual void Update(float deltaTime) { UNREFERENCED(deltaTime); } protected: element& m_element; private: controller(const controller&) = delete; controller(const controller&&) = delete; controller& operator = (const controller&) = delete; }; } // ui
#ifndef FE_EVENT_PARSER_H_ #define FE_EVENT_PARSER_H_ #include "FE_Libs.h" //#include "CScanner_CLexer.h" enum FE_EVENT_PAIR_TYPE{ FE_NO_COMBO = 0, FE_AND_COMBO = 1, FE_OR_COMBO = 2 }; /// class intended to store a pair (or no pair) of events /// equivalent to CNode* for the parser class FE_EventPair{ friend class FE_EventParser; friend class FE_EventHandler; public: FE_EventPair(); ~FE_EventPair(); protected: FE_EVENT_PAIR_TYPE pair_type; FE_EventPair* event0; FE_EventPair* event1; string name; }; ///FE_EventParser, only parser is needed class FE_EventParser{ public: FE_EventParser(); ~FE_EventParser(); FE_EventPair parse(string); FE_EventPair* parseComparison(FE_EventPair&); protected: string info; }; //asdf #endif
#ifndef _EASYANIM_SKELETON_IMPL_H_ #define _EASYANIM_SKELETON_IMPL_H_ #include <ee/ArrangeSpriteImpl.h> namespace eanim { class Joint; class SkeletonImpl : public ee::ArrangeSpriteImpl { public: SkeletonImpl(); virtual bool OnKeyDown(int keyCode) override; virtual void OnMouseLeftDown(int x, int y) override; virtual void OnMouseLeftUp(int x, int y) override; virtual void OnMouseRightDown(int x, int y) override; virtual void OnMouseDrag(int x, int y) override; virtual void OnPopMenuSelected(int type) override; virtual void OnDraw(float cam_scale) const override; protected: virtual void SetRightPopupMenu(wxMenu& menu, int x, int y) override; virtual ee::ArrangeSpriteState* CreateTranslateState(ee::SpriteSelection* selection, const sm::vec2& first_pos) const override; virtual ee::ArrangeSpriteState* CreateRotateState(ee::SpriteSelection* selection, const sm::vec2& first_pos) const override; private: Joint* m_selected_joint; sm::vec2 m_first_pos; }; // SkeletonImpl } #endif // _EASYANIM_SKELETON_IMPL_H_
// // UITextView+HDValidation.h // Pods // // Created by Dailingchi on 15/7/28. // // #import <UIKit/UIKit.h> #import "HDValidationDefines.h" @interface UITextView (HDValidation) <HDValidation> @end
#ifdef USE_SPEEX #include "sdy_def.h" #include <speex/speex.h> #include <memory.h> #include <malloc.h> #pragma comment(lib, "libspeex.lib") typedef struct SPEEX_INFO { void* hf; SDY_IO io; SpeexBits bits; void* dec_state; int frame_size; sdyByte* tmp; float* buf; } SPEEX_INFO; void* SDYSTRMAPI SPEEX_Open( const char* szFile, SDY_WFX* pwfx, SDY_IO* io, sdyDword dwFlags) { SPEEX_INFO* pInfo; pInfo = malloc(sizeof(SPEEX_INFO)); memset(pInfo, 0, sizeof(SPEEX_INFO)); pInfo->hf = io->open(szFile, "rb"); if(!pInfo->hf) { free(pInfo); return 0; } pInfo->io = *io; speex_bits_init(&pInfo->bits); pInfo->dec_state = speex_decoder_init(&speex_wb_mode); speex_decoder_ctl(pInfo->dec_state, SPEEX_GET_FRAME_SIZE, &pInfo->frame_size); pInfo->tmp = malloc(sizeof(sdyByte) * pInfo->frame_size); pInfo->buf = malloc(sizeof(float) * pInfo->frame_size); return pInfo; } sdyDword SDYSTRMAPI SPEEX_Stream( void* _pInfo, sdyByte* pBuffer, sdyDword dwBytes) { int len; SPEEX_INFO* pInfo = _pInfo; if(!pInfo->io.read(&len, 4, 1, pInfo->hf)) return 0; pInfo->io.read(pInfo->tmp, len, 1, pInfo->hf); speex_bits_read_from(&pInfo->bits, pInfo->tmp, len); speex_decode(pInfo->dec_state, &pInfo->bits, pInfo->buf); return 0; } sdyBool SDYSTRMAPI SPEEX_Close(void* _pInfo) { SPEEX_INFO* pInfo = _pInfo; if(pInfo->hf) pInfo->io.close(pInfo->hf); speex_bits_destroy(&pInfo->bits); speex_decoder_destroy(pInfo->dec_state); free(pInfo); return sdyTrue; } #endif // USE_SPEEX
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE78_OS_Command_Injection__wchar_t_connect_socket_w32_execvp_18.c Label Definition File: CWE78_OS_Command_Injection.strings.label.xml Template File: sources-sink-18.tmpl.c */ /* * @description * CWE: 78 OS Command Injection * BadSource: connect_socket Read data using a connect socket (client side) * GoodSource: Fixed string * Sink: w32_execvp * BadSink : execute command with wexecvp * Flow Variant: 18 Control flow: goto statements * * */ #include "std_testcase.h" #include <wchar.h> #ifdef _WIN32 #define COMMAND_INT_PATH L"%WINDIR%\\system32\\cmd.exe" #define COMMAND_INT L"cmd.exe" #define COMMAND_ARG1 L"/c" #define COMMAND_ARG2 L"dir" #define COMMAND_ARG3 data #else /* NOT _WIN32 */ #include <unistd.h> #define COMMAND_INT_PATH L"/bin/sh" #define COMMAND_INT L"sh" #define COMMAND_ARG1 L"ls" #define COMMAND_ARG2 L"-la" #define COMMAND_ARG3 data #endif #ifdef _WIN32 #include <winsock2.h> #include <windows.h> #include <direct.h> #pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */ #define CLOSE_SOCKET closesocket #else /* NOT _WIN32 */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #define CLOSE_SOCKET close #define SOCKET int #endif #define TCP_PORT 27015 #define IP_ADDRESS "127.0.0.1" #include <process.h> #define EXECVP _wexecvp #ifndef OMITBAD void CWE78_OS_Command_Injection__wchar_t_connect_socket_w32_execvp_18_bad() { wchar_t * data; wchar_t dataBuffer[100] = L""; data = dataBuffer; goto source; source: { #ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0; #endif int recvResult; struct sockaddr_in service; wchar_t *replace; SOCKET connectSocket = INVALID_SOCKET; size_t dataLen = wcslen(data); do { #ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) { break; } wsaDataInit = 1; #endif /* POTENTIAL FLAW: Read data using a connect socket */ connectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (connectSocket == INVALID_SOCKET) { break; } memset(&service, 0, sizeof(service)); service.sin_family = AF_INET; service.sin_addr.s_addr = inet_addr(IP_ADDRESS); service.sin_port = htons(TCP_PORT); if (connect(connectSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR) { break; } /* Abort on error or the connection was closed, make sure to recv one * less char than is in the recv_buf in order to append a terminator */ /* Abort on error or the connection was closed */ recvResult = recv(connectSocket, (char *)(data + dataLen), sizeof(wchar_t) * (100 - dataLen - 1), 0); if (recvResult == SOCKET_ERROR || recvResult == 0) { break; } /* Append null terminator */ data[dataLen + recvResult / sizeof(wchar_t)] = L'\0'; /* Eliminate CRLF */ replace = wcschr(data, L'\r'); if (replace) { *replace = L'\0'; } replace = wcschr(data, L'\n'); if (replace) { *replace = L'\0'; } } while (0); if (connectSocket != INVALID_SOCKET) { CLOSE_SOCKET(connectSocket); } #ifdef _WIN32 if (wsaDataInit) { WSACleanup(); } #endif } { wchar_t *args[] = {COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG2, COMMAND_ARG3, NULL}; /* wexecvp - searches for the location of the command among * the directories specified by the PATH environment variable */ /* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */ EXECVP(COMMAND_INT, args); } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() - use goodsource and badsink by reversing the blocks on the goto statement */ static void goodG2B() { wchar_t * data; wchar_t dataBuffer[100] = L""; data = dataBuffer; goto source; source: /* FIX: Append a fixed string to data (not user / external input) */ wcscat(data, L"*.*"); { wchar_t *args[] = {COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG2, COMMAND_ARG3, NULL}; /* wexecvp - searches for the location of the command among * the directories specified by the PATH environment variable */ /* POTENTIAL FLAW: Execute command without validating input possibly leading to command injection */ EXECVP(COMMAND_INT, args); } } void CWE78_OS_Command_Injection__wchar_t_connect_socket_w32_execvp_18_good() { goodG2B(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on * its own for testing or for building a binary to use in testing binary * analysis tools. It is not used when compiling all the testcases as one * application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE78_OS_Command_Injection__wchar_t_connect_socket_w32_execvp_18_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE78_OS_Command_Injection__wchar_t_connect_socket_w32_execvp_18_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/******************************************************************************/ /*! file M5Phy.h \author Matt Casanova \\par email: lazersquad\@gmail.com \par Mach5 Game Engine \date 2016/09/26 Basis Physics engine for Mach 5. This is a work in progress. */ /******************************************************************************/ #ifndef M5PHY_H #define M5PHY_H #include <vector> //Forward Declarations class ColliderComponent; //! Typedef name for my pairs of collided objectIDs typedef std::vector < std::pair<int, int> > CollisionPairs; //! Singleton class to test collision between pairs of M5Objects class M5Phy { public: friend class M5StageManager; //Registers a collider with the physics engine static void RegisterCollider(ColliderComponent* pCollider); //Unregisters a collider with the physics engine static void UnregisterCollider(ColliderComponent* pCollider); //Gets all pairs of objects that collided this frame. static void GetCollisionPairs(CollisionPairs& pairs); //Marks a pair of M5Objects as having collided. static void AddCollisionPair(int firstID, int secondID); private: static void Update(void); static void Pause(void); static void Resume(void); }; #endif //M5PHY_H
/* Copyright (c) 2004-2006 Jesper Svennevid, Daniel Collin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef zenic_ps2_ExporterBackend_h #define zenic_ps2_ExporterBackend_h /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// class CSLXSIShape; class CSLXSIMaterial; namespace zenic { class String; namespace ps2 { class ModelData; class Texture; class Dma; } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "../ExporterBackend.h" #include <Shared/Base/Types.h> #include <Shared/Base/Math/Vector3.h> #include <Shared/Base/Math/Color32.h> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// namespace zenic { namespace ps2 { /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// class ExporterBackend : public zenic::ExporterBackend { public : ExporterBackend() {} ~ExporterBackend() {} zenic::ModelData* buildModelData(CSLModel* model, zenic::Model* modelNode); zenic::Model* buildModel(CSLModel* mesh); zenic::Material* buildMaterial(CSLXSIMaterial* xsiMaterial); Serializable* buildTexture(CSLImage* image, CSIBCPixMap& pixMap); private: typedef struct { Vector3 vertex; Color32 color; Vector3 normal; float s; float t; uint adc; } MeshVertex; enum VertexFlags { Position = 1, Color = 2, Normal = 4, Texcoord = 8, PositionInt = 16 }; enum { Vu1ChunkSize = 490, // usually about half size of vu-memory Vu0ChunkSize = 128 }; void calculateBound(CSLXSIShape* shape, zenic::Model* modelNode); void setupVertexFormat(CSLXSIShape* shape); void setupShaderPipeline(ps2::ModelData* modelData, const char* name); void flushChunk(Dma& dmaChain); void addVertex(Dma& dmaChain, const Vector3& vertex, const Color32& color, const Vector3& normal, const float& s, const float& t, const uint& adc); void getChain(ModelData* target, Dma& dmaChain); u32 m_chunkCount; u32 m_chunkSize; u32 m_cycleFormat; u32 m_vertexFormat; u32 m_vertexOffset; Vector3 m_maxScale; static MeshVertex m_buildChunk[256]; static uint m_vu1HeaderSize; }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } } #endif
#ifndef MMU_H #define MMU_H #include <iostream> #include <cstring> #include "PCE.h" #include "HuC6270.h" #include "HuC6280.h" #include "render.h" class HuC6270; class HuC6280; /* Interrupt Vectors */ #define INTERRUPT_TIME 0xFFFA #define INTERRUPT_IRQ1 0xFFF8 class MMU { public: MMU(); ~MMU(); unsigned char readMemory(unsigned short addr); unsigned char readMPRi(unsigned char n); unsigned char readIO(unsigned short addr); unsigned char getTimerStart(); unsigned char readStack(unsigned short addr); unsigned short readVRAM(unsigned short addr); void writeStack(unsigned short addr, unsigned char data); void writeMemory(unsigned short addr, unsigned char data); void writeIO(unsigned short addr, unsigned char data); void writeVRAM(unsigned short addr, unsigned short data); void setMPRi(unsigned char n, unsigned char data); void clearMPR(); void writeLog(std::string text); void setupVDC(HuC6270 *vdc); void setupCPU(HuC6280 *cpu); void setupRender(render *r); bool startMemory(); bool isTimerEnable(); unsigned char* getVRAM(); private: PCE pceLoader; bool timerEnable; unsigned char timerStart; unsigned char mpr [0x8]; unsigned char wram [0x8000]; unsigned char HuCardROM [0x100000]; unsigned char vram [0x10000]; unsigned char interruptMask; // CPU can access some registers of HuC6270(VDC) and HuC6260(VCE) // So we will use *ptr to solve it =) HuC6270* VDC; HuC6280* CPU; render* mRender; // Only for debug purpose, log system FILE *log; }; #endif
#ifndef __UINT64_H__ #define __UINT64_H__ # include "config.h" # ifdef HAS_INTTYPES_H # include <inttypes.h> typedef uint64_t uint64; # elif HAS_64BIT_ULL typedef unsigned long long uint64; # elif HAS_64BIT_UL typedef unsigned long uint64; # elif HAS_64BIT_U typedef unsigned uint64; # elif HAS_64BIT_US typedef unsigned short uint64; # else # error "No 64-bit type detected" # endif #endif /* __UINT64_H__ */
#include <linux/module.h> #include <linux/spi/spi.h> #include "vgatonic.h" // Change these to something appropriate for your board. #define SPI_BUS_SPEED 32000000 #define SPI_BUS_SPEED_WS 32000000 // Based on x/640/480/8 #define SPI_FRAMES_PER_SECOND 12.75 // Based on x/848/480/8 #define SPI_FRAMES_PER_SECOND_WS 9.75 /* For many boards, only the next few lines need to be changed */ #define SPI_BUS 0 #define SPI_BUS_CS1 0 /* Define the pseudo chip select. We need this so we can hold it low for up to 307200 times in a row for a full screen write in 640*480*8 without the hardware SPI Device interfering */ #define FAKE_CS 103 // Define the maximum number of SPI writes your hardware can support. For many, it's unlimited, so use 307200. #define MAX_SPI_WRITES 407040 // Do we want to use widescreen? This macro sets it up in the kernel. // When you insmod or modprobe, use "insmod <thismodule>.ko widescreen=1" and widescreen mode will turn on static int widescreen = 0; /* default to no, use 4:3 */ module_param(widescreen, bool, 0644); /* a Boolean type */ const char this_driver_name[] = "vgatonic_card_on_spi"; static struct vgatonicfb_platform_data vgatonicfb_data = { .cs_gpio = FAKE_CS, .spi_speed = SPI_BUS_SPEED, .spi_frames_per_second = SPI_FRAMES_PER_SECOND, .spi_speed_ws = SPI_BUS_SPEED_WS, .spi_frames_per_second_ws= SPI_FRAMES_PER_SECOND_WS, .max_spi_writes = MAX_SPI_WRITES, }; static int __init add_vgatonicfb_device_to_bus(void) { struct spi_master *spi_master; struct spi_device *spi_device; struct device *pdev; char buff[64]; int status = 0; spi_master = spi_busnum_to_master(SPI_BUS); if (!spi_master) { printk(KERN_ALERT "spi_busnum_to_master(%d) returned NULL\n", SPI_BUS); printk(KERN_ALERT "Missing modprobe spi device?\n"); return -1; } spi_device = spi_alloc_device(spi_master); if (!spi_device) { put_device(&spi_master->dev); printk(KERN_ALERT "spi_alloc_device() failed\n"); return -1; } /* specify a chip select line */ spi_device->chip_select = SPI_BUS_CS1; /* Check whether this SPI bus.cs is already claimed */ snprintf(buff, sizeof(buff), "%s.%u", dev_name(&spi_device->master->dev), spi_device->chip_select); pdev = bus_find_device_by_name(spi_device->dev.bus, NULL, buff); /* If the bus is claimed, that is expected. Unregister whatever is there. If we weren't doing this driver so quickly, we'd give it the bus back when you're done. */ if ( pdev && pdev->driver && pdev->driver->name && strcmp(this_driver_name, pdev->driver->name) ) { printk(KERN_ALERT "Driver [%s] already registered for %s.\nRemoving it from the bus for VGATonic to occupy it.", pdev->driver->name, buff); spi_unregister_device( pdev ); } /* All the rules we're set to print - use mode 3! Don't push the speed too high! */ spi_device->dev.platform_data = &vgatonicfb_data; struct vgatonicfb_platform_data *pdata = spi_device->dev.platform_data; if (widescreen) { pdata->useWidescreen = true; spi_device->max_speed_hz = SPI_BUS_SPEED_WS; } else { pdata->useWidescreen = false; spi_device->max_speed_hz = SPI_BUS_SPEED; } spi_device->mode = SPI_MODE_3; spi_device->bits_per_word = 8; spi_device->irq = -1; spi_device->controller_state = NULL; spi_device->controller_data = NULL; strlcpy(spi_device->modalias, this_driver_name, SPI_NAME_SIZE); /* Adding the VGATonic SPI Device */ status = spi_add_device(spi_device); if (status < 0) { spi_dev_put(spi_device); printk(KERN_ALERT "spi_add_device() failed: %d\n", status); } put_device(&spi_master->dev); return status; } module_init(add_vgatonicfb_device_to_bus); static void __exit rpi_vgatonicfb_exit(void) { } module_exit(rpi_vgatonicfb_exit); MODULE_DESCRIPTION("SPI driver for VGATonic SPI VGA display controller Odroid C1"); MODULE_AUTHOR("PK"); MODULE_LICENSE("GPL");
/* * spi.c * * Created on: Oct 15, 2017 * Author: t400 */ #include "spi.h" // init SPI in master mode with F_CPU / 128 prescaler, and setup ChipSelect pin void spi_init(uint8_t CSN){ //If SS is configured as an input, it must be held high to ensure Master SPI operation DDRB |= (1 << DD_SCK) | (1 << DD_MOSI) | (1 << CSN); SPCR |= (1 << SPR1) | ( 1 << SPR0 ) | (1 << MSTR) | (1 << SPE); SETBIT(PORTB, PB2); SETBIT(PORTB, CSN); } // sending a byte over SPI. ChipSelect management not included uint8_t spi_transfer(uint8_t data){ SPDR = data; while(!(SPSR & BIT(SPIF) )); // wait until this transmission is complete return SPDR; }
// // CRAppDelegate.h // CRBoost // // Created by Eric Wu on 08/15/2018. // Copyright (c) 2018 Eric Wu. All rights reserved. // @import UIKit; @interface CRAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
// // STRVOAuthView.h // strava-objc // // Created by Eric Ito on 11/22/13. // // #import <UIKit/UIKit.h> @class STRVOAuthAuthorization; @interface STRVOAuthView : UIView /// called when either an access token is retrieved or some error occurs @property (nonatomic, copy) void(^completion)(NSString *accessToken, NSError *error); - (void)loadAuthorization:(STRVOAuthAuthorization*)authorization; @end
/* The MIT License (MIT) Copyright (c) 2013 Vincent de RIBOU <belzo2005-dolphin@yahoo.fr> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*! * \file boz_queue_new.c * \brief Message creation implementation. * \version 0.1 * \date 2013/01/14 * \author Vincent de RIBOU. * \copyright Aquaplouf Land. * */ #include <errno.h> #include "boz_queue_p.h" boz_msg_queue_t boz_msg_queue_new(const boz_msg_params_t* const p) { unsigned int id=-1; boz_queue_internal_t *pi=NULL; boz_msg_params_t *pp=(boz_msg_params_t*)p; if(!pp) pp = &boz_msg_params_zero; switch(p->type) { case BOZ_MSG_TYPE_RAW: case BOZ_MSG_TYPE_BASIC: break; default: return (errno=EINVAL,-1); } if(!gensetdyn_new(&boz_queue_g.storage, &id)) return (errno=ENOSPC,-1); pi = (boz_queue_internal_t*)gensetdyn_p(&boz_queue_g.storage, id); (*pi) = boz_queue_internal_zero; pi->id = id; pi->params = *pp; // pi->data = stralloc_zero; if(pi->params.size) { stralloc_ready(&pi->data, pi->params.size); } return (errno=0,id); }
#import <Foundation/Foundation.h> #import "SentryScope.h" #import "SentryScopeObserver.h" @class SentryAttachment; NS_ASSUME_NONNULL_BEGIN @interface SentryScope (Private) @property (atomic, strong, readonly) NSArray<SentryAttachment *> *attachments; @property (atomic, strong) SentryUser *_Nullable userObject; - (void)addObserver:(id<SentryScopeObserver>)observer; @end NS_ASSUME_NONNULL_END
/* * Generated by class-dump 3.3.4 (64 bit). * * class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2011 by Steve Nygard. */ #import "CoreDAVPostTask.h" @class CalDAVScheduleResponseItem, NSArray, NSString; @interface CalDAVScheduleTask : CoreDAVPostTask { NSArray *_attendees; NSString *_originator; CalDAVScheduleResponseItem *_scheduleResponse; } @property(retain) NSArray *attendees; // @synthesize attendees=_attendees; @property(retain) NSString *originator; // @synthesize originator=_originator; @property(retain) CalDAVScheduleResponseItem *scheduleResponse; // @synthesize scheduleResponse=_scheduleResponse; - (void)finishCoreDAVTaskWithError:(id)arg1; - (id)copyDefaultParserForContentType:(id)arg1; - (id)additionalHeaderValues; - (id)initWithOriginator:(id)arg1 attendees:(id)arg2 outboxURL:(id)arg3 payload:(id)arg4; - (void)dealloc; @end
/** \file * \brief Cairo Double Buffer Driver * * See Copyright Notice in cd.h */ #include "cdcairoctx.h" #include "cddbuf.h" #include <stdlib.h> #include <stdio.h> static void cdkillcanvas (cdCtxCanvas* ctxcanvas) { cdKillImage(ctxcanvas->image_dbuffer); ctxcanvas->cr = NULL; /* avoid to destroy it twice */ cdcairoKillCanvas(ctxcanvas); } static void cddeactivate(cdCtxCanvas* ctxcanvas) { cdCanvas* canvas_dbuffer = ctxcanvas->canvas_dbuffer; /* this is done in the canvas_dbuffer context */ cdCanvasDeactivate(canvas_dbuffer); } static void cdflush(cdCtxCanvas* ctxcanvas) { int old_writemode; cdImage* image_dbuffer = ctxcanvas->image_dbuffer; cdCanvas* canvas_dbuffer = ctxcanvas->canvas_dbuffer; /* flush the writing in the image */ cairo_show_page(ctxcanvas->cr); /* this is done in the canvas_dbuffer context */ /* Flush can be affected by Origin and Clipping, but not WriteMode */ old_writemode = cdCanvasWriteMode(canvas_dbuffer, CD_REPLACE); cdCanvasPutImageRect(canvas_dbuffer, image_dbuffer, 0, 0, 0, 0, 0, 0); cdCanvasWriteMode(canvas_dbuffer, old_writemode); } static void cdcreatecanvas(cdCanvas* canvas, cdCanvas* canvas_dbuffer) { int w, h; cdCtxCanvas* ctxcanvas; cdImage* image_dbuffer; cdCtxImage* ctximage; cdCanvasActivate(canvas_dbuffer); w = canvas_dbuffer->w; h = canvas_dbuffer->h; if (w==0) w=1; if (h==0) h=1; /* this is done in the canvas_dbuffer context */ image_dbuffer = cdCanvasCreateImage(canvas_dbuffer, w, h); if (!image_dbuffer) return; ctximage = image_dbuffer->ctximage; /* Init the driver DBuffer */ ctxcanvas = cdcairoCreateCanvas(canvas, ctximage->cr); if (!ctxcanvas) return; ctxcanvas->image_dbuffer = image_dbuffer; ctxcanvas->canvas_dbuffer = canvas_dbuffer; canvas->w = ctximage->w; canvas->h = ctximage->h; canvas->w_mm = ctximage->w_mm; canvas->h_mm = ctximage->h_mm; canvas->bpp = ctximage->bpp; canvas->xres = ctximage->xres; canvas->yres = ctximage->yres; } static int cdactivate(cdCtxCanvas* ctxcanvas) { int w, h; cdCanvas* canvas_dbuffer = ctxcanvas->canvas_dbuffer; /* this is done in the canvas_dbuffer context */ /* this will update canvas size */ cdCanvasActivate(canvas_dbuffer); w = canvas_dbuffer->w; h = canvas_dbuffer->h; if (w==0) w=1; if (h==0) h=1; /* check if the size changed */ if (w != ctxcanvas->image_dbuffer->w || h != ctxcanvas->image_dbuffer->h) { cdCanvas* canvas = ctxcanvas->canvas; /* save the current, if the rebuild fail */ cdImage* old_image_dbuffer = ctxcanvas->image_dbuffer; cdCtxCanvas* old_ctxcanvas = ctxcanvas; /* if the image is rebuild, the canvas that uses the image must be also rebuild */ /* rebuild the image and the canvas */ canvas->ctxcanvas = NULL; canvas->context->cxCreateCanvas(canvas, canvas_dbuffer); if (!canvas->ctxcanvas) { canvas->ctxcanvas = old_ctxcanvas; return CD_ERROR; } /* remove the old image and canvas */ cdKillImage(old_image_dbuffer); old_ctxcanvas->cr = NULL; /* avoid to destroy it twice */ cdcairoKillCanvas(old_ctxcanvas); ctxcanvas = canvas->ctxcanvas; /* update canvas attributes */ cdUpdateAttributes(canvas); } return CD_OK; } static void cdinittable(cdCanvas* canvas) { cdcairoInitTable(canvas); canvas->cxActivate = cdactivate; canvas->cxDeactivate = cddeactivate; canvas->cxFlush = cdflush; canvas->cxKillCanvas = cdkillcanvas; } static cdContext cdDBufferContext = { CD_CAP_ALL & ~(CD_CAP_PLAY | CD_CAP_YAXIS | CD_CAP_REGION | CD_CAP_WRITEMODE | CD_CAP_PALETTE ), CD_CTX_IMAGE|CD_CTX_PLUS, cdcreatecanvas, cdinittable, NULL, NULL, }; cdContext* cdContextCairoDBuffer(void) { return &cdDBufferContext; }
// // ViewController.h // Khaki // // Created by George Czabania on 3/01/15. // Copyright (c) 2015 Mintcode. All rights reserved. // #import <UIKit/UIKit.h> #import <CommonCrypto/CommonHMAC.h> @import CoreBluetooth; @import CoreLocation; #define KHAKI_UNLOCKED 0x01 #define KHAKI_NOTIFYING 0x02 #define KHAKI_SERVICE_UUID [CBUUID UUIDWithString:@"54a64ddf-c756-4a1a-bf9d-14f2cac357ad"] #define KHAKI_CAR_CHARACTERISTIC_UUID [CBUUID UUIDWithString:@"fd1c6fcc-3ca5-48a9-97e9-37f81f5bd9c5"] #define KHAKI_AUTH_CHARACTERISTIC_UUID [CBUUID UUIDWithString:@"66e01614-13d1-40d6-a34f-c5360ba57698"] #define KHAKI_BEACON_UUID [[NSUUID alloc] initWithUUIDString:@"a78d9129-b79a-400f-825e-b691661123eb"] @interface ViewController : UIViewController <CBCentralManagerDelegate, CBPeripheralDelegate, CLLocationManagerDelegate> @property (nonatomic, strong) CBCentralManager *centralManager; @property (nonatomic, strong) CBPeripheral *peripheral; @property (nonatomic, strong) NSUUID *peripheralUUID; @property (nonatomic) BOOL isInsideRegion; @property (nonatomic) BOOL isUnlocked; @property (nonatomic) BOOL isRanging; @property (nonatomic, strong) CLLocationManager *locationManager; @property (nonatomic, strong) CLBeaconRegion *beaconRegion; @property (nonatomic, strong) CBCharacteristic *authCharacteristic; @property (nonatomic, strong) CBCharacteristic *carCharacteristic; @property (weak, nonatomic) IBOutlet UITextView *connectedLabel; @property (weak, nonatomic) IBOutlet UILabel *iBeaconLabel; @property (weak, nonatomic) IBOutlet UILabel *carStatusLabel; @end
/* * The MIT License (MIT) * * Copyright (c) 2014 Josef Gajdusek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef _INPUTVIEW_H #define _INPUTVIEW_H #include <Button.h> #include <Message.h> #include <String.h> #include <TextControl.h> #include "DialogView.h" class InputView : public DialogView { public: InputView(BRect frame, BString title, BString initial="", BString bstr="OK"); virtual ~InputView(); virtual void MessageReceived(BMessage* msg); virtual void AttachedToWindow(); private: BTextControl* fTextControl; BButton* fButton; }; #endif
// // MyPageChildSecondVC.h // test_jobQuestions // // Created by Jingnan Zhang on 2017/5/12. // Copyright © 2017年 Jingnan Zhang. All rights reserved. // #import <UIKit/UIKit.h> @interface MyPageChildSecondVC : UIViewController @end
// // AppDelegate.h // UI_UIGesture // // Created by qianfeng on 15/7/9. // Copyright (c) 2015年 qianfeng32. All rights reserved. // #import <UIKit/UIKit.h> #import <CoreData/CoreData.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; - (void)saveContext; - (NSURL *)applicationDocumentsDirectory; @end
#ifndef AL_VECTOR_H #define AL_VECTOR_H #include <stdlib.h> #include <AL/al.h> #include "almalloc.h" /* "Base" vector type, designed to alias with the actual vector types. */ typedef struct vector__s { size_t Capacity; size_t Size; } *vector_; #define TYPEDEF_VECTOR(T, N) typedef struct { \ size_t Capacity; \ size_t Size; \ T Data[]; \ } _##N; \ typedef _##N* N; \ typedef const _##N* const_##N; #define VECTOR(T) struct { \ size_t Capacity; \ size_t Size; \ T Data[]; \ }* #define VECTOR_INIT(_x) do { (_x) = NULL; } while(0) #define VECTOR_INIT_STATIC() NULL #define VECTOR_DEINIT(_x) do { al_free((_x)); (_x) = NULL; } while(0) /* Helper to increase a vector's reserve. Do not call directly. */ ALboolean vector_reserve(char *ptr, size_t base_size, size_t obj_size, size_t obj_count, ALboolean exact); #define VECTOR_RESERVE(_x, _c) (vector_reserve((char*)&(_x), sizeof(*(_x)), sizeof((_x)->Data[0]), (_c), AL_TRUE)) ALboolean vector_resize(char *ptr, size_t base_size, size_t obj_size, size_t obj_count); #define VECTOR_RESIZE(_x, _c) (vector_resize((char*)&(_x), sizeof(*(_x)), sizeof((_x)->Data[0]), (_c))) #define VECTOR_CAPACITY(_x) ((_x) ? (_x)->Capacity : 0) #define VECTOR_SIZE(_x) ((_x) ? (_x)->Size : 0) #define VECTOR_BEGIN(_x) ((_x) ? (_x)->Data + 0 : NULL) #define VECTOR_END(_x) ((_x) ? (_x)->Data + (_x)->Size : NULL) #define VECTOR_PUSH_BACK(_x, _obj) (vector_reserve((char*)&(_x), sizeof(*(_x)), sizeof((_x)->Data[0]), VECTOR_SIZE(_x)+1, AL_FALSE) && \ (((_x)->Data[(_x)->Size++] = (_obj)),AL_TRUE)) #define VECTOR_POP_BACK(_x) ((void)((_x)->Size--)) #define VECTOR_BACK(_x) ((_x)->Data[(_x)->Size-1]) #define VECTOR_FRONT(_x) ((_x)->Data[0]) #define VECTOR_ELEM(_x, _o) ((_x)->Data[(_o)]) #define VECTOR_FOR_EACH(_t, _x, _f) do { \ _t *_iter = VECTOR_BEGIN((_x)); \ _t *_end = VECTOR_END((_x)); \ for(;_iter != _end;++_iter) \ _f(_iter); \ } while(0) #define VECTOR_FOR_EACH_PARAMS(_t, _x, _f, ...) do { \ _t *_iter = VECTOR_BEGIN((_x)); \ _t *_end = VECTOR_END((_x)); \ for(;_iter != _end;++_iter) \ _f(__VA_ARGS__, _iter); \ } while(0) #define VECTOR_FIND_IF(_i, _t, _x, _f) do { \ _t *_iter = VECTOR_BEGIN((_x)); \ _t *_end = VECTOR_END((_x)); \ for(;_iter != _end;++_iter) \ { \ if(_f(_iter)) \ break; \ } \ (_i) = _iter; \ } while(0) #define VECTOR_FIND_IF_PARMS(_i, _t, _x, _f, ...) do { \ _t *_iter = VECTOR_BEGIN((_x)); \ _t *_end = VECTOR_END((_x)); \ for(;_iter != _end;++_iter) \ { \ if(_f(__VA_ARGS__, _iter)) \ break; \ } \ (_i) = _iter; \ } while(0) #endif /* AL_VECTOR_H */
// // NUAction+Serialization.h // NextUserKit // // Created by NextUser on 12/10/15. // Copyright © 2015 NextUser. All rights reserved. // #import "NUAction.h" #import "NUTrackable.h" @interface NUAction (Serialization) <NUTrackable> @end
#ifndef List_h #define List_h class Node { public: int value; Node *link; }; class List { public: void print(); void reverse(); void add(int value); List () { first = 0; } private: Node *first; void print(Node *p); }; #endif
// // GPKGTransactionTestCase.h // geopackage-iosTests // // Created by Brian Osborn on 9/19/19. // Copyright © 2019 NGA. All rights reserved. // #import "GPKGCreateGeoPackageTestCase.h" @interface GPKGTransactionTestCase : GPKGCreateGeoPackageTestCase @end
@interface GoalsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> { NSMutableArray *goals; UITableView *tableView; } @property (nonatomic, retain) NSArray *goals; @property (nonatomic, retain) IBOutlet UITableView *tableView; - (IBAction)add; - (IBAction)refresh; @end
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2019 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef SYSCOIN_WALLET_ISMINE_H #define SYSCOIN_WALLET_ISMINE_H #include <script/standard.h> #include <stdint.h> #include <bitset> class CWallet; class CScript; /** IsMine() return codes */ enum isminetype : unsigned int { ISMINE_NO = 0, ISMINE_WATCH_ONLY = 1 << 0, ISMINE_SPENDABLE = 1 << 1, ISMINE_USED = 1 << 2, ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE, ISMINE_ALL_USED = ISMINE_ALL | ISMINE_USED, ISMINE_ENUM_ELEMENTS, }; /** used for bitflags of isminetype */ typedef uint8_t isminefilter; /** * Cachable amount subdivided into watchonly and spendable parts. */ struct CachableAmount { // NO and ALL are never (supposed to be) cached std::bitset<ISMINE_ENUM_ELEMENTS> m_cached; CAmount m_value[ISMINE_ENUM_ELEMENTS]; inline void Reset() { m_cached.reset(); } void Set(isminefilter filter, CAmount value) { m_cached.set(filter); m_value[filter] = value; } }; #endif // SYSCOIN_WALLET_ISMINE_H
#ifndef __MARS_TASK_SIGNAL_H__ #define __MARS_TASK_SIGNAL_H__ #include <ppu-types.h> #include <mars/task_types.h> #ifdef __cplusplus extern "C" { #endif /** * \ingroup group_mars_task_signal */ int mars_task_signal_send(struct mars_task_id *id); #ifdef __cplusplus } #endif #endif
#include "../Tests.h" #include "../NamespacesBase/NamespacesBase.h" // Namespace clashes with NamespacesBase.OverlappingNamespace // Test whether qualified names turn out right. namespace OverlappingNamespace { class InDerivedLib { public: InDerivedLib(); Base parentNSComponent; ColorsEnum color; }; } // Using a type imported from a different library. class DLL_API Derived : public Base2 { public: Derived(); Base baseComponent; Base getBase(); void setBase(Base); void parent(int i); OverlappingNamespace::InBaseLib nestedNSComponent; OverlappingNamespace::InBaseLib getNestedNSComponent(); void setNestedNSComponent(OverlappingNamespace::InBaseLib); OverlappingNamespace::ColorsEnum color; private: int d; }; // For reference: using a type derived in the same library class Base3 { }; template <typename T> class TemplateClass; class Derived2 : public Base3 { public: Base3 baseComponent; Base3 getBase(); void setBase(Base3); OverlappingNamespace::InDerivedLib nestedNSComponent; OverlappingNamespace::InDerivedLib getNestedNSComponent(); void setNestedNSComponent(OverlappingNamespace::InDerivedLib); void defaultEnumValueFromDependency(OverlappingNamespace::ColorsEnum c = OverlappingNamespace::ColorsEnum::black); Abstract* getAbstract(); private: TemplateClass<int> t; TemplateClass<Derived> d; }; class DLL_API HasVirtualInDependency : public HasVirtualInCore { public: HasVirtualInDependency(); HasVirtualInDependency* managedObject; int callManagedOverride(); }; class DLL_API DerivedFromExternalSpecialization : public TemplateWithIndependentFields<Derived> { public: DerivedFromExternalSpecialization(int i, TemplateWithIndependentFields<HasVirtualInDependency> defaultExternalSpecialization = TemplateWithIndependentFields<HasVirtualInDependency>()); ~DerivedFromExternalSpecialization(); TemplateWithIndependentFields<Base3> returnExternalSpecialization(); }; class DLL_API DerivedFromSecondaryBaseInDependency : public Derived, public SecondaryBase { public: DerivedFromSecondaryBaseInDependency(); ~DerivedFromSecondaryBaseInDependency(); }; DLL_API bool operator<<(const Base& b, const char* str); namespace NamespacesBase { class DLL_API ClassInNamespaceNamedAfterDependency { private: Base base; }; }
// // Generated by class-dump 3.5 (64 bit). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard. // #import "CDStructures.h" #import <IDEKit/IDERunSheetPhaseModel.h> @interface IDERunSheetLaunchPhaseModel : IDERunSheetPhaseModel { } + (id)keyPathsForValuesAffectingNavigableItem_name; - (id)schemeCommandTitle; - (int)schemePhaseModelCommand; - (id)navigableItem_image; - (id)navigableItem_name; - (Class)detailViewControllerClass; - (id)runPhase; @end
#ifndef PREPROCESSOR_REPETITION_ENUM_TRAILING_BINARY_PARAMS_H #define PREPROCESSOR_REPETITION_ENUM_TRAILING_BINARY_PARAMS_H #include <preprocessor/cat.h> #include <preprocessor/repetition/repeat.h> #include <preprocessor/tuple/elem.h> #include <preprocessor/tuple/rem.h> #define PP_ENUM_TRAILING_BINARY_PARAMS(count, p1, p2) PP_REPEAT(count, PP_ENUM_TRAILING_BINARY_PARAMS_M, (p1, p2)) #define PP_ENUM_TRAILING_BINARY_PARAMS_M(z, n, pp) PP_ENUM_TRAILING_BINARY_PARAMS_M_I(z, n, PP_TUPLE_ELEM(2, 0, pp), PP_TUPLE_ELEM(2, 1, pp)) #define PP_ENUM_TRAILING_BINARY_PARAMS_M_I(z, n, p1, p2) , PP_CAT(p1, n) PP_CAT(p2, n) #define PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, count, p1, p2) PP_REPEAT_ ## z(count, PP_ENUM_TRAILING_BINARY_PARAMS_M, (p1, p2)) #endif
// // Generated by the J2ObjC translator. DO NOT EDIT! // source: android/libcore/luni/src/main/java/java/lang/IllegalMonitorStateException.java // #include "../../J2ObjC_header.h" #pragma push_macro("INCLUDE_ALL_JavaLangIllegalMonitorStateException") #ifdef RESTRICT_JavaLangIllegalMonitorStateException #define INCLUDE_ALL_JavaLangIllegalMonitorStateException 0 #else #define INCLUDE_ALL_JavaLangIllegalMonitorStateException 1 #endif #undef RESTRICT_JavaLangIllegalMonitorStateException #pragma clang diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #if !defined (JavaLangIllegalMonitorStateException_) && (INCLUDE_ALL_JavaLangIllegalMonitorStateException || defined(INCLUDE_JavaLangIllegalMonitorStateException)) #define JavaLangIllegalMonitorStateException_ #define RESTRICT_JavaLangRuntimeException 1 #define INCLUDE_JavaLangRuntimeException 1 #include "../../java/lang/RuntimeException.h" /*! @brief Thrown when a monitor operation is attempted when the monitor is not in the correct state, for example when a thread attempts to exit a monitor which it does not own. */ @interface JavaLangIllegalMonitorStateException : JavaLangRuntimeException #pragma mark Public /*! @brief Constructs a new <code>IllegalMonitorStateException</code> that includes the current stack trace. */ - (instancetype)init; /*! @brief Constructs a new <code>IllegalArgumentException</code> with the current stack trace and the specified detail message. @param detailMessage the detail message for this exception. */ - (instancetype)initWithNSString:(NSString *)detailMessage; @end J2OBJC_EMPTY_STATIC_INIT(JavaLangIllegalMonitorStateException) FOUNDATION_EXPORT void JavaLangIllegalMonitorStateException_init(JavaLangIllegalMonitorStateException *self); FOUNDATION_EXPORT JavaLangIllegalMonitorStateException *new_JavaLangIllegalMonitorStateException_init() NS_RETURNS_RETAINED; FOUNDATION_EXPORT JavaLangIllegalMonitorStateException *create_JavaLangIllegalMonitorStateException_init(); FOUNDATION_EXPORT void JavaLangIllegalMonitorStateException_initWithNSString_(JavaLangIllegalMonitorStateException *self, NSString *detailMessage); FOUNDATION_EXPORT JavaLangIllegalMonitorStateException *new_JavaLangIllegalMonitorStateException_initWithNSString_(NSString *detailMessage) NS_RETURNS_RETAINED; FOUNDATION_EXPORT JavaLangIllegalMonitorStateException *create_JavaLangIllegalMonitorStateException_initWithNSString_(NSString *detailMessage); J2OBJC_TYPE_LITERAL_HEADER(JavaLangIllegalMonitorStateException) #endif #pragma clang diagnostic pop #pragma pop_macro("INCLUDE_ALL_JavaLangIllegalMonitorStateException")
#pragma once #include <ntddk.h> /// <summary> /// Perform LSTAR hooking /// </summary> /// <returns>Status code</returns> NTSTATUS SHInitHook(); /// <summary> /// Hook specific SSDT entry /// </summary> /// <param name="index">SSDT index</param> /// <param name="hookPtr">Hook address</param> /// <param name="argCount">Number of function arguments</param> /// <returns>Status code</returns> NTSTATUS SHHookSyscall( IN ULONG index, IN PVOID hookPtr, IN CHAR argCount ); /// <summary> /// Restore original SSDT entry /// </summary> /// <param name="index">SSDT index</param> /// <returns>Status code</returns> NTSTATUS SHRestoreSyscall( IN ULONG index ); /// <summary> /// Unhook LSTAR /// </summary> /// <returns>Status code</returns> NTSTATUS SHDestroyHook();
// Copyright (c) Tamas Csala /** @file rectangle_shape.h @brief Implements an NDC rectangle shape. */ #ifndef OGLWRAP_SHAPES_RECTANGLE_SHAPE_H_ #define OGLWRAP_SHAPES_RECTANGLE_SHAPE_H_ #include <set> #include <vector> #include "../buffer.h" #include "../context.h" #include "../vertex_array.h" #include "../vertex_attrib.h" namespace OGLWRAP_NAMESPACE_NAME { class RectangleShape { public: enum AttributeType {kPosition, kTexCoord}; /// Constructs a rectangle that covers the entire screen NDC space. explicit RectangleShape(const std::set<AttributeType>& attribs = {kPosition}); /// Renders the rectangle. /** This call changes the currently active VAO. */ void render(); /// Returns the face winding of the cube created by this class. FaceOrientation faceWinding() const { return FaceOrientation::kCw; } private: VertexArray vao_; ArrayBuffer buffer_; static const int kAttribTypeNum = 2; static void createAttrib(std::vector<glm::vec2>* data, AttributeType type); static void createPositions(std::vector<glm::vec2>* data); static void createTexCoords(std::vector<glm::vec2>* data); }; } // namespace oglwrap #include "./rectangle_shape-inl.h" #endif // OGLWRAP_SHAPES_FULLSCREENRECT_H_
#include<stdio.h> #include<stdlib.h> #include<string.h> typedef struct hash_buckets_s { char* key; void* value; struct hash_buckets_s* next; } hash_buckets_t; typedef struct hasht_s { hash_buckets_t** buckets; size_t size; } hasht_t; hasht_t* hasht_create(size_t size); void hasht_free(hasht_t* hasht); int hasht_insert(hasht_t* hasht, const char* key, void* value); int hasht_remove(hasht_t* hasht, const char* key); void* hasht_get(hasht_t* hasht, const char* key);
#pragma once class NaiveSearch { public: static int search(char *needle, int needleLength, char *haystack, int haystackLength); };
/************************************************************************************************* Usage: the following function tags a W-jet: bool wtag(ClusterSequence & clustSeq, PseudoJet &jet, double signal_eff = -1, jet_pars *jetpars_ptr = NULL) return value: true = tagged, false = not tagged clustSeq = the ClusterSequence the jet belongs to jet = jet to be tagged signal_eff = signal efficiency, default = efficiency maximizing S/sqrt(B) jetpars_ptr = pointer to jet parameters, default = NULL, using default parameters The variables are stored in class jet_mvars (see below). To obtain the variables, first define jet paramemters jet_pars jetpars; jetpars.read_jetpars(); Use jet_mvars::get_mvars(ClusterSequence &, PseudoJet &, jet_pars &) to calculate the variables. For example, jet_mvars jet_mvars; jetmvars.get_mvars(clustSeq, jet, jetpars); Then one can use jet_mvars::foutput(ofstream &) to output the variables to a file *************************************************************************************************/ #ifndef WTAG #define WTAG #include "fastjet/PseudoJet.hh" #include "fastjet/ClusterSequence.hh" #define NPT 18 //number of pt bins #define PI 3.1415926535 #define NEFF 1000 //using namespace fastjet; // GAH! namespace Wtag { class jet_pars //class to save jet algorithm parameters { public: void read_jetpars(); double get_Rsub(double pt); double get_fcut(double pt); double get_Rcut(double pt); double get_zcut(double pt); double get_mu(double pt); double get_ycut(double pt); double get_bdtcut_opt(double pt); double get_bdtcut_opt_es(double pt); double get_bdtcut_opt_eb(double pt); double get_bdtcut_opt_sig(double pt); double get_bdtcut(double pt, double es); double get_bdtcut_es(double pt, double es); double get_bdtcut_eb(double pt, double es); double get_bdtcut_sig(double pt, double es); double get_filtering_es(double pt); double get_filtering_eb(double pt); double get_filtering_sig(double pt); void set_trimming_par_file(char*); void set_pruning_par_file(char*); void set_filtering_par_file(char*); void set_bdtcut_filename(char*); void set_bdteff_filename(char*); void set_bdtweight_dir(char*); void set_bdtweight_prefix(char*); void set_bdtweight_name(double pt, char*); void get_trimming_par_file(char*); void get_pruning_par_file(char*); void get_filtering_par_file(char*); void get_bdtcut_filename(char*); void get_bdteff_filename(char*); void get_bdtweight_dir(char*); void get_bdtweight_prefix(char*); void get_bdtweight_name(double pt, char*); jet_pars(); private: //trimming parameters double Rsub[NPT]; double fcut[NPT]; //pruning parameters double Rcut[NPT]; double zcut[NPT]; //filtering parameters double mu[NPT]; double ycut[NPT]; double filtering_es[NPT]; double filtering_eb[NPT]; double filtering_sig[NPT]; bool initiated; char trimming_par_file[200]; char pruning_par_file[200]; char filtering_par_file[200]; char bdtcut_filename[200]; //file containing the best BDT cuts char bdteff_filename[200]; //file containing BDT cuts as a function of signal efficiency char bdtweight_dir[100]; char bdtweight_prefix[100]; char bdtweight_name[NPT][100]; bool bdtweights_set[NPT]; double bdtcuts_opt[NPT]; double bdtcuts_opt_es[NPT]; double bdtcuts_opt_eb[NPT]; double bdtcuts_opt_sig[NPT]; double bdtcuts[NPT][NEFF]; double bdtcuts_es[NPT][NEFF]; double bdtcuts_eb[NPT][NEFF]; double bdtcuts_sig[NPT][NEFF]; }; class jet_mvars //class to calculate and save variables { public: double mass, pt, masstrim, pttrim, massprune, ptprune, massfilter, ptfilter; double ptratio, pangle1, psize1, pangle2, psize2; double mass2, mass3, mass4, mass5, mass6, mass7, mass8, mass9, mass10, mass11; double pt2, pt3, pt4, pt5, pt6, pt7, pt8, pt9, pt10, pt11; int nsubjets; double ptsub1, ptsub2, masssub1, masssub2, subjetdR; double rapsub1, rapsub2, phisub1, phisub2; double planarflow, planarflow4; double pfilter[4]; bool get_mvars(fastjet::ClusterSequence & clustSeq, fastjet::PseudoJet & jet, jet_pars &jetpars); bool finput(std::ifstream &fin); void foutput(std::ofstream &fout); }; bool wtag(fastjet::ClusterSequence & clustSeq, fastjet::PseudoJet &jet, double signal_eff = -1, jet_pars * jetpars_ptr = NULL); //pass BDT cut = true, otherwise = false //if signal_eff < 0, use cuts maximizing significance, stored in jetpars_prt->bestBDTcuts[ipt] //if signal_eff specified, using cuts cooresponding to the signal efficiency int cal_ipt(double pt); int cal_ieff(double eff); } // namespace Wtag #endif
/* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) * * Copyright (c) 2013-2017 Damien P. George * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "py/mpstate.h" #if MICROPY_NLR_X64 #undef nlr_push // x86-64 callee-save registers are: // rbx, rbp, rsp, r12, r13, r14, r15 __attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr); unsigned int nlr_push(nlr_buf_t *nlr) { (void)nlr; #if MICROPY_NLR_OS_WINDOWS __asm volatile ( "movq (%rsp), %rax \n" // load return %rip "movq %rax, 16(%rcx) \n" // store %rip into nlr_buf "movq %rbp, 24(%rcx) \n" // store %rbp into nlr_buf "movq %rsp, 32(%rcx) \n" // store %rsp into nlr_buf "movq %rbx, 40(%rcx) \n" // store %rbx into nlr_buf "movq %r12, 48(%rcx) \n" // store %r12 into nlr_buf "movq %r13, 56(%rcx) \n" // store %r13 into nlr_buf "movq %r14, 64(%rcx) \n" // store %r14 into nlr_buf "movq %r15, 72(%rcx) \n" // store %r15 into nlr_buf "movq %rdi, 80(%rcx) \n" // store %rdr into nlr_buf "movq %rsi, 88(%rcx) \n" // store %rsi into nlr_buf "jmp nlr_push_tail \n" // do the rest in C ); #else __asm volatile ( #if defined(__APPLE__) || defined(__MACH__) "pop %rbp \n" // undo function's prelude #endif "movq (%rsp), %rax \n" // load return %rip "movq %rax, 16(%rdi) \n" // store %rip into nlr_buf "movq %rbp, 24(%rdi) \n" // store %rbp into nlr_buf "movq %rsp, 32(%rdi) \n" // store %rsp into nlr_buf "movq %rbx, 40(%rdi) \n" // store %rbx into nlr_buf "movq %r12, 48(%rdi) \n" // store %r12 into nlr_buf "movq %r13, 56(%rdi) \n" // store %r13 into nlr_buf "movq %r14, 64(%rdi) \n" // store %r14 into nlr_buf "movq %r15, 72(%rdi) \n" // store %r15 into nlr_buf #if defined(__APPLE__) || defined(__MACH__) "jmp _nlr_push_tail \n" // do the rest in C #else "jmp nlr_push_tail \n" // do the rest in C #endif ); #endif return 0; // needed to silence compiler warning } NORETURN void nlr_jump(void *val) { MP_NLR_JUMP_HEAD(val, top) __asm volatile ( "movq %0, %%rcx \n" // %rcx points to nlr_buf #if MICROPY_NLR_OS_WINDOWS "movq 88(%%rcx), %%rsi \n" // load saved %rsi "movq 80(%%rcx), %%rdi \n" // load saved %rdr #endif "movq 72(%%rcx), %%r15 \n" // load saved %r15 "movq 64(%%rcx), %%r14 \n" // load saved %r14 "movq 56(%%rcx), %%r13 \n" // load saved %r13 "movq 48(%%rcx), %%r12 \n" // load saved %r12 "movq 40(%%rcx), %%rbx \n" // load saved %rbx "movq 32(%%rcx), %%rsp \n" // load saved %rsp "movq 24(%%rcx), %%rbp \n" // load saved %rbp "movq 16(%%rcx), %%rax \n" // load saved %rip "movq %%rax, (%%rsp) \n" // store saved %rip to stack "xorq %%rax, %%rax \n" // clear return register "inc %%al \n" // increase to make 1, non-local return "ret \n" // return : // output operands : "r"(top) // input operands : // clobbered registers ); MP_UNREACHABLE } #endif // MICROPY_NLR_X64
#pragma once #include <windows.h> #include <stdio.h> #include <vector> #include <map> /// The |canvas| is the main drawing area of our /// control: the place where we will draw the images. /// It will be partitioned into a grid of |bubbles|. /// An |atomic bubbles| corresponds to the cells of the /// grid. They can be merged to larger bubbles. /// These bubbles are the zones into which images /// will be dropped and in which images will be drawn. /// In this module, we will deal with the merging of /// atomic bubbles into larger ones. /// Non-atomic bubbles are a.k.a. |groups|. using Id = unsigned int; struct geometry_t { size_t cols; size_t rows; }; struct groups_t { /// A |group| is an integer (|Id|) that identifies /// either an atomic bubble (right after |reset| /// is called) or a set of bubbles that have been /// merged together. std::vector<Id> data; void reset(unsigned int count) { data.resize(count); for(unsigned int i=0; i<count; ++i) data[i] = i; } // Id & merge(Id a, Id b) { // /// Make the |a|-th item have the same value // /// as the |b|-th item; the value will be the // /// lesser of their previous values (if they // /// were different). IOW after every item pair // /// had been merged, all items will have the // /// value 0. // Id const & le = a <= b ? a : b; // Id const & ge = a <= b ? b : a; // data[ge] = data[le]; // return data[ge]; // } void print() const { for(auto it : data) { printf("%d ", it); } printf("\n"); } }; struct mappings_t { std::map<Id, Id *> links; groups_t & groups; mappings_t(groups_t & groups) : groups(groups) { } void reset(unsigned int count) { links.clear(); groups.reset(count); } void assign(Id key, Id value) { links[key] = &groups.data[value]; } void print() const { groups.print(); for(auto p : links) printf("= %d -> %d\n", p.first, *p.second); } }; /// ok let's think this trough. /// we have a vector of drawables (e.g. rectangles): v1. /// we have an index: index = [0 1 2 3 4 5] /// so: index[2] = 2, etc. /// now we merge two rectangles: 1 + 2 /// it means we need a second vector of drawables: v2. /// v2 will hold the merged rectangles and index needs /// to point the source rectangle's indices to the /// new dest rectangle index. /// But we also need to distinguish between indices into /// v1 and indices into v2; it is best to have only one /// kind of index: indices into v2; but this would mean /// copying the whole of v1 into v2 at init; though we /// could get away with mere references (weak copies). /// /// // template<class T> // struct mergable_i { // virtual mergable_i merge_with(mergable_i & other) = 0; // }; template<class T> struct matrix_t { std::map<Id, Id> links; std::vector<T> * mergables; matrix_t() : mergables(nullptr) { } void attach(std::vector<T> & mergables) { this->mergables = &mergables; links.clear(); for(size_t i=0; i<mergables.size(); ++i) { links[i] = i; } } void merge(Id a, Id b) { printf("-- matrix: merging %d with %d\n", a, b); links[a] = b; } void print() const { printf("-- marix: printing\n"); for(auto link : links) printf(" %d->%d", link.first, link.second); } }; // class matrix_t { // // geometry_t geometry; // mappings_t mappings; // groups_t groups; // public: // matrix_t() : mappings(groups) { // } // void reset(geometry_t const & g={1,1}) { // printf("matrix: resetting to geometry" // " (%d,%d)\n", g.cols, g.rows); // geometry = g; // mappings.reset(geometry.cols * geometry.rows); // } // void merge(Id a, Id b) { // /// The run-down. // /// 0. The user has just joined two rects. // /// 1. We create a new rect (a+b) from the // /// two rects pointed to by a and b. // /// 2. And point slots a and b -> (a+b). // static Id dummy = 4711; // Id const & m = a <= b ? a : b; // mappings.assign(a, m); // mappings.assign(b, m); // } // void print() const { // mappings.print(); // printf("\n"); // } // };
#include <math.h> #define SGS_CPPBC_WITH_STD_STRING #define SGS_CPPBC_WITH_STD_VECTOR #include "cppbc/sgs_cppbc.h" struct Vec3 { SGS_OBJECT_LITE; Vec3( float _x, float _y, float _z ) : x(_x), y(_y), z(_z){} float _get_length(){ return (float) sqrtf(x*x+y*y+z*z); } SGS_PROPERTY float x; SGS_PROPERTY float y; SGS_PROPERTY float z; SGS_PROPERTY_FUNC( READ _get_length ) SGS_ALIAS( float length ); SGS_METHOD float getLength(){ return _get_length(); } SGS_METHOD void setLength( float len ) { if( x == 0 && y == 0 && z == 0 ) x = 1; else { float ol = _get_length(); len /= ol; } x *= len; y *= len; z *= len; } SGS_IFUNC( CONVERT ) int _convert( SGS_CTX, sgs_VarObj* data, int type ) { Vec3* V = (Vec3*) data->data; if( type == SGS_VT_STRING ) { char bfr[ 128 ] = {0}; snprintf( bfr, 127, "Vec3(%g;%g;%g)", V->x, V->y, V->z ); sgs_PushString( C, bfr ); return SGS_SUCCESS; } return SGS_ENOTSUP; } }; class Account { public: Account() : maybeIntTest2(42), bitfieldTest1(true) { vectorTest2.push_back( 1337 ); stdStringTest2 = "test"; } typedef sgsHandle< Account > Handle; SGS_OBJECT; SGS_PROPERTY sgsString name; SGS_PROPERTY_FUNC( READ WRITE VARNAME name2 ) SGS_ALIAS( sgsString name ); SGS_PROPERTY Handle attached; SGS_GCREF( attached ); SGS_NODUMP( attached ); SGS_PROPERTY_FUNC( READ WRITE VALIDATE attached.not_null() SOURCE attached->name ) SGS_ALIAS( sgsString attachedName ); SGS_PROPERTY sgsMaybe<int> maybeIntTest1; SGS_PROPERTY sgsMaybe<int> maybeIntTest2; SGS_PROPERTY bool bitfieldTest1 : 1; SGS_PROPERTY sgsVariable sgsVarTest1; SGS_PROPERTY Handle handleTest1; std::vector< int > vectorTest1; SGS_DUMP( vectorTest1 ); std::vector< int > vectorTest2; SGS_DUMP( vectorTest2 ); SGS_PROPERTY std::string stdStringTest1; SGS_PROPERTY std::string stdStringTest2; /* `Handle` must be resolved since it's going to be used out of scope */ SGS_METHOD bool sendMoney( Account::Handle to, float amount, sgsString currency ) { if( !to.not_null() ) { printf( "--- sending money ---\n! recipient not specified\n" ); return false; } printf( "--- sending money ---\nfrom: %.*s\nto: %.*s\namount: %.4f\ncurrency: %.*s\n---\n", name.size(), name.c_str(), to->name.size(), to->name.c_str(), amount, currency.size(), currency.c_str() ); return true; } // purposefully compacted formatting SGS_METHOD_NAMED( coroAware ) int sgsCoroAware(int a,SGS_CTX,int b,sgs_Context* c,int d){ return a + b + ( C == c ) + ( C == this->C ) + d; } SGS_IFUNC( CONVERT ) int _convert( SGS_CTX, sgs_VarObj* data, int type ) { Account* A = (Account*) data->data; if( type == SGS_VT_STRING ) { sgs_PushString( C, "Account(" ); A->name.push( C ); sgs_PushString( C, ")" ); sgs_StringConcat( C, 3 ); return SGS_SUCCESS; } return SGS_ENOTSUP; } };
#ifndef __INTERRUPT_H_ #define __INTERRUPT_H_ void setup_interrupts(); void is_install_handler(int interrupt, void *service_routine, int dpl); void is_install_hook( void(*hook)() ); extern "C" void is_c8259(void); extern "C" void is_cstub(void); extern "C" void is_cpanic(void); extern "C" void is_cpic(int pic); extern "C" void is_ctimer(void); extern "C" void is_ckeyboard(void); extern "C" void is_capi(unsigned int a, unsigned int b, unsigned int c, unsigned int d); #endif
#ifndef CFLAGS_H #define CFLAGS_H #include <sys/types.h> template<typename T> class CFlags { public: using enum_type = T; private: uint value_; public: // constructors CFlags() : value_(0) { reset(); } CFlags(T value) : value_(static_cast<int>(value)) { } // copy/assign CFlags(const CFlags &flags) : value_(flags.value_) { } CFlags &operator=(const CFlags &flags) { value_ = flags.value_; return *this; } // enum value T value() const { return static_cast<T>(value_); } // conversion operator int() const { return value_; } //operator T() const { return value(); } // operators //CFlags &operator&=(int flag) { value_ &= flag; return *this; } //CFlags &operator&=(uint flag) { value_ &= flag; return *this; } CFlags operator &=(CFlags flags) { value_ &= flags.value_; return *this; } CFlags operator &=(T flag ) { value_ &= flag ; return *this; } //CFlags operator &(int flag) const { CFlags t(*this); t &= flag ; return t; } //CFlags operator &(uint flag) const { CFlags t(*this); t &= flag ; return t; } CFlags operator &(CFlags flags) const { CFlags t(*this); t &= flags; return t; } CFlags operator &(T flag ) const { CFlags t(*this); t &= flag ; return t; } CFlags &operator|=(CFlags flags) { value_ |= flags.value_; return *this; } CFlags &operator|=(T flag ) { value_ |= flag ; return *this; } CFlags operator|(CFlags flags) const { CFlags t(*this); t |= flags; return t; } CFlags operator|(T flag ) const { CFlags t(*this); t |= flag ; return t; } CFlags &operator^=(CFlags flags) { value_ ^= flags.value_; return *this; } CFlags &operator^=(T flag ) { value_ ^= flag ; return *this; } CFlags operator^(CFlags flags) const { CFlags t(*this); t ^= flags; return t; } CFlags operator^(T flag ) const { CFlags t(*this); t ^= flag ; return t; } CFlags operator~() const { CFlags t; t.value_ = ~value_; return t; } //bool operator!() const { return ! isSet(); } // functions bool isSet() const { return (value_ != 0); } void set () { value_ = ~0; } void reset() { value_ = 0; } void invert() { value_ = ~value_; } CFlags &add(CFlags flags) { *this |= flags; return *this; } CFlags &add(T flag) { value_ |= flag; return *this; } CFlags &remove(CFlags flags) { *this &= ~flags; return *this; } CFlags &remove(T flag) { value_ &= ~flag; return *this; } CFlags &addRemove(CFlags flags, bool b) { if (b) return add(flags); else return remove(flags); } CFlags &addRemove(T flag, bool b) { if (b) return add(flag); else return remove(flag); } bool test(CFlags flags) const { return (value_ & flags.value_); } bool test(T flag ) const { return (value_ & flag ); } }; #define CFLAGS_OPERATORS(T) \ inline CFlags<T> operator|(T f1, T f2) { return CFlags<T>(f1) | f2; } \ \ inline CFlags<T> operator|(T f1, CFlags<T> f2) { return f2 | f1; } #endif
#pragma once #include "../common/config.h" #include "../common/clock.h" namespace co { template <typename T> struct ChannelImpl : public IdCounter<ChannelImpl<T>> { virtual ~ChannelImpl() {} virtual bool Push(T t, bool bWait, FastSteadyClock::time_point deadline = FastSteadyClock::time_point{}) = 0; virtual bool Pop(T & t, bool bWait, FastSteadyClock::time_point deadline = FastSteadyClock::time_point{}) = 0; virtual void Close() = 0; virtual std::size_t Size() = 0; virtual bool Empty() = 0; }; } // namespace co