text:
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif

#include "rpc.h"
#include "rpcndr.h"

#ifndef __RPCNDR_H_VERSION__
#error This stub requires an updated version of <rpcndr.h>
#endif

#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif

#ifndef __indexsrv_h__
#define __indexsrv_h__

#ifndef __IPhraseSink_FWD_DEFINED__
#define __IPhraseSink_FWD_DEFINED__
typedef struct IPhraseSink IPhraseSink;
#endif

#ifndef __IWordSink_FWD_DEFINED__
#define __IWordSink_FWD_DEFINED__
typedef struct IWordSink IWordSink;
#endif

#ifndef __IWordBreaker_FWD_DEFINED__
#define __IWordBreaker_FWD_DEFINED__
typedef struct IWordBreaker IWordBreaker;
#endif

#ifndef __IWordFormSink_FWD_DEFINED__
#define __IWordFormSink_FWD_DEFINED__
typedef struct IWordFormSink IWordFormSink;
#endif

#ifndef __IStemmer_FWD_DEFINED__
#define __IStemmer_FWD_DEFINED__
typedef struct IStemmer IStemmer;
#endif

#ifndef __ISimpleCommandCreator_FWD_DEFINED__
#define __ISimpleCommandCreator_FWD_DEFINED__
typedef struct ISimpleCommandCreator ISimpleCommandCreator;
#endif

#ifndef __IColumnMapper_FWD_DEFINED__
#define __IColumnMapper_FWD_DEFINED__
typedef struct IColumnMapper IColumnMapper;
#endif

#ifndef __IColumnMapperCreator_FWD_DEFINED__
#define __IColumnMapperCreator_FWD_DEFINED__
typedef struct IColumnMapperCreator IColumnMapperCreator;
#endif

#include "oaidl.h"
#include "filter.h"

#ifdef __cplusplus
extern "C"{
#endif

#ifndef __MIDL_user_allocate_free_DEFINED__
#define __MIDL_user_allocate_free_DEFINED__
  void *__RPC_API MIDL_user_allocate(size_t);
  void __RPC_API MIDL_user_free(void *);
#endif

#ifndef __IPhraseSink_INTERFACE_DEFINED__
#define __IPhraseSink_INTERFACE_DEFINED__

  EXTERN_C const IID IID_IPhraseSink;

#if defined(__cplusplus) && !defined(CINTERFACE)
  struct IPhraseSink : public IUnknown {
  public:
    virtual HRESULT WINAPI PutSmallPhrase(const WCHAR *pwcNoun,ULONG cwcNoun,const WCHAR *pwcModifier,ULONG cwcModifier,ULONG ulAttachmentType) = 0;
    virtual HRESULT WINAPI PutPhrase(const WCHAR *pwcPhrase,ULONG cwcPhrase) = 0;
  };
#else
  typedef struct IPhraseSinkVtbl {
    BEGIN_INTERFACE
      HRESULT (WINAPI *QueryInterface)(IPhraseSink *This,REFIID riid,void **ppvObject);
      ULONG (WINAPI *AddRef)(IPhraseSink *This);
      ULONG (WINAPI *Release)(IPhraseSink *This);
      HRESULT (WINAPI *PutSmallPhrase)(IPhraseSink *This,const WCHAR *pwcNoun,ULONG cwcNoun,const WCHAR *pwcModifier,ULONG cwcModifier,ULONG ulAttachmentType);
      HRESULT (WINAPI *PutPhrase)(IPhraseSink *This,const WCHAR *pwcPhrase,ULONG cwcPhrase);
    END_INTERFACE
  } IPhraseSinkVtbl;
  struct IPhraseSink {
    CONST_VTBL struct IPhraseSinkVtbl *lpVtbl;
  };
#ifdef COBJMACROS
#define IPhraseSink_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define IPhraseSink_AddRef(This) (This)->lpVtbl->AddRef(This)
#define IPhraseSink_Release(This) (This)->lpVtbl->Release(This)
#define IPhraseSink_PutSmallPhrase(This,pwcNoun,cwcNoun,pwcModifier,cwcModifier,ulAttachmentType) (This)->lpVtbl->PutSmallPhrase(This,pwcNoun,cwcNoun,pwcModifier,cwcModifier,ulAttachmentType)
#define IPhraseSink_PutPhrase(This,pwcPhrase,cwcPhrase) (This)->lpVtbl->PutPhrase(This,pwcPhrase,cwcPhrase)
#endif
#endif
  HRESULT WINAPI IPhraseSink_PutSmallPhrase_Proxy(IPhraseSink *This,const WCHAR *pwcNoun,ULONG cwcNoun,const WCHAR *pwcModifier,ULONG cwcModifier,ULONG ulAttachmentType);
  void __RPC_STUB IPhraseSink_PutSmallPhrase_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IPhraseSink_PutPhrase_Proxy(IPhraseSink *This,const WCHAR *pwcPhrase,ULONG cwcPhrase);
  void __RPC_STUB IPhraseSink_PutPhrase_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
#endif

#ifndef __IWordSink_INTERFACE_DEFINED__
#define __IWordSink_INTERFACE_DEFINED__
#ifndef _tagWORDREP_BREAK_TYPE_DEFINED
#define _tagWORDREP_BREAK_TYPE_DEFINED
  typedef enum tagWORDREP_BREAK_TYPE {
    WORDREP_BREAK_EOW = 0,WORDREP_BREAK_EOS = 1,WORDREP_BREAK_EOP = 2,WORDREP_BREAK_EOC = 3
  } WORDREP_BREAK_TYPE;
#define _WORDREP_BREAK_TYPE_DEFINED
#endif

  EXTERN_C const IID IID_IWordSink;
#if defined(__cplusplus) && !defined(CINTERFACE)
  struct IWordSink : public IUnknown {
  public:
    virtual HRESULT WINAPI PutWord(ULONG cwc,const WCHAR *pwcInBuf,ULONG cwcSrcLen,ULONG cwcSrcPos) = 0;
    virtual HRESULT WINAPI PutAltWord(ULONG cwc,const WCHAR *pwcInBuf,ULONG cwcSrcLen,ULONG cwcSrcPos) = 0;
    virtual HRESULT WINAPI StartAltPhrase(void) = 0;
    virtual HRESULT WINAPI EndAltPhrase(void) = 0;
    virtual HRESULT WINAPI PutBreak(WORDREP_BREAK_TYPE breakType) = 0;
  };
#else
  typedef struct IWordSinkVtbl {
    BEGIN_INTERFACE
      HRESULT (WINAPI *QueryInterface)(IWordSink *This,REFIID riid,void **ppvObject);
      ULONG (WINAPI *AddRef)(IWordSink *This);
      ULONG (WINAPI *Release)(IWordSink *This);
      HRESULT (WINAPI *PutWord)(IWordSink *This,ULONG cwc,const WCHAR *pwcInBuf,ULONG cwcSrcLen,ULONG cwcSrcPos);
      HRESULT (WINAPI *PutAltWord)(IWordSink *This,ULONG cwc,const WCHAR *pwcInBuf,ULONG cwcSrcLen,ULONG cwcSrcPos);
      HRESULT (WINAPI *StartAltPhrase)(IWordSink *This);
      HRESULT (WINAPI *EndAltPhrase)(IWordSink *This);
      HRESULT (WINAPI *PutBreak)(IWordSink *This,WORDREP_BREAK_TYPE breakType);
    END_INTERFACE
  } IWordSinkVtbl;
  struct IWordSink {
    CONST_VTBL struct IWordSinkVtbl *lpVtbl;
  };
#ifdef COBJMACROS
#define IWordSink_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define IWordSink_AddRef(This) (This)->lpVtbl->AddRef(This)
#define IWordSink_Release(This) (This)->lpVtbl->Release(This)
#define IWordSink_PutWord(This,cwc,pwcInBuf,cwcSrcLen,cwcSrcPos) (This)->lpVtbl->PutWord(This,cwc,pwcInBuf,cwcSrcLen,cwcSrcPos)
#define IWordSink_PutAltWord(This,cwc,pwcInBuf,cwcSrcLen,cwcSrcPos) (This)->lpVtbl->PutAltWord(This,cwc,pwcInBuf,cwcSrcLen,cwcSrcPos)
#define IWordSink_StartAltPhrase(This) (This)->lpVtbl->StartAltPhrase(This)
#define IWordSink_EndAltPhrase(This) (This)->lpVtbl->EndAltPhrase(This)
#define IWordSink_PutBreak(This,breakType) (This)->lpVtbl->PutBreak(This,breakType)
#endif
#endif
  HRESULT WINAPI IWordSink_PutWord_Proxy(IWordSink *This,ULONG cwc,const WCHAR *pwcInBuf,ULONG cwcSrcLen,ULONG cwcSrcPos);
  void __RPC_STUB IWordSink_PutWord_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IWordSink_PutAltWord_Proxy(IWordSink *This,ULONG cwc,const WCHAR *pwcInBuf,ULONG cwcSrcLen,ULONG cwcSrcPos);
  void __RPC_STUB IWordSink_PutAltWord_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IWordSink_StartAltPhrase_Proxy(IWordSink *This);
  void __RPC_STUB IWordSink_StartAltPhrase_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IWordSink_EndAltPhrase_Proxy(IWordSink *This);
  void __RPC_STUB IWordSink_EndAltPhrase_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IWordSink_PutBreak_Proxy(IWordSink *This,WORDREP_BREAK_TYPE breakType);
  void __RPC_STUB IWordSink_PutBreak_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
#endif

#ifndef _tagTEXT_SOURCE_DEFINED
#define _tagTEXT_SOURCE_DEFINED
  typedef HRESULT (WINAPI *PFNFILLTEXTBUFFER)(struct tagTEXT_SOURCE *pTextSource);
  typedef struct tagTEXT_SOURCE {
    PFNFILLTEXTBUFFER pfnFillTextBuffer;
    const WCHAR *awcBuffer;
    ULONG iEnd;
    ULONG iCur;
  } TEXT_SOURCE;
#define _TEXT_SOURCE_DEFINED
#endif

  extern RPC_IF_HANDLE __MIDL_itf_indexsrv_0127_v0_0_c_ifspec;
  extern RPC_IF_HANDLE __MIDL_itf_indexsrv_0127_v0_0_s_ifspec;

#ifndef __IWordBreaker_INTERFACE_DEFINED__
#define __IWordBreaker_INTERFACE_DEFINED__
  EXTERN_C const IID IID_IWordBreaker;
#if defined(__cplusplus) && !defined(CINTERFACE)
  struct IWordBreaker : public IUnknown {
  public:
    virtual HRESULT WINAPI Init(WINBOOL fQuery,ULONG ulMaxTokenSize,WINBOOL *pfLicense) = 0;
    virtual HRESULT WINAPI BreakText(TEXT_SOURCE *pTextSource,IWordSink *pWordSink,IPhraseSink *pPhraseSink) = 0;
    virtual HRESULT WINAPI ComposePhrase(const WCHAR *pwcNoun,ULONG cwcNoun,const WCHAR *pwcModifier,ULONG cwcModifier,ULONG ulAttachmentType,WCHAR *pwcPhrase,ULONG *pcwcPhrase) = 0;
    virtual HRESULT WINAPI GetLicenseToUse(const WCHAR **ppwcsLicense) = 0;
  };
#else
  typedef struct IWordBreakerVtbl {
    BEGIN_INTERFACE
      HRESULT (WINAPI *QueryInterface)(IWordBreaker *This,REFIID riid,void **ppvObject);
      ULONG (WINAPI *AddRef)(IWordBreaker *This);
      ULONG (WINAPI *Release)(IWordBreaker *This);
      HRESULT (WINAPI *Init)(IWordBreaker *This,WINBOOL fQuery,ULONG ulMaxTokenSize,WINBOOL *pfLicense);
      HRESULT (WINAPI *BreakText)(IWordBreaker *This,TEXT_SOURCE *pTextSource,IWordSink *pWordSink,IPhraseSink *pPhraseSink);
      HRESULT (WINAPI *ComposePhrase)(IWordBreaker *This,const WCHAR *pwcNoun,ULONG cwcNoun,const WCHAR *pwcModifier,ULONG cwcModifier,ULONG ulAttachmentType,WCHAR *pwcPhrase,ULONG *pcwcPhrase);
      HRESULT (WINAPI *GetLicenseToUse)(IWordBreaker *This,const WCHAR **ppwcsLicense);
    END_INTERFACE
  } IWordBreakerVtbl;
  struct IWordBreaker {
    CONST_VTBL struct IWordBreakerVtbl *lpVtbl;
  };
#ifdef COBJMACROS
#define IWordBreaker_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define IWordBreaker_AddRef(This) (This)->lpVtbl->AddRef(This)
#define IWordBreaker_Release(This) (This)->lpVtbl->Release(This)
#define IWordBreaker_Init(This,fQuery,ulMaxTokenSize,pfLicense) (This)->lpVtbl->Init(This,fQuery,ulMaxTokenSize,pfLicense)
#define IWordBreaker_BreakText(This,pTextSource,pWordSink,pPhraseSink) (This)->lpVtbl->BreakText(This,pTextSource,pWordSink,pPhraseSink)
#define IWordBreaker_ComposePhrase(This,pwcNoun,cwcNoun,pwcModifier,cwcModifier,ulAttachmentType,pwcPhrase,pcwcPhrase) (This)->lpVtbl->ComposePhrase(This,pwcNoun,cwcNoun,pwcModifier,cwcModifier,ulAttachmentType,pwcPhrase,pcwcPhrase)
#define IWordBreaker_GetLicenseToUse(This,ppwcsLicense) (This)->lpVtbl->GetLicenseToUse(This,ppwcsLicense)
#endif
#endif
  HRESULT WINAPI IWordBreaker_Init_Proxy(IWordBreaker *This,WINBOOL fQuery,ULONG ulMaxTokenSize,WINBOOL *pfLicense);
  void __RPC_STUB IWordBreaker_Init_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IWordBreaker_BreakText_Proxy(IWordBreaker *This,TEXT_SOURCE *pTextSource,IWordSink *pWordSink,IPhraseSink *pPhraseSink);
  void __RPC_STUB IWordBreaker_BreakText_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IWordBreaker_ComposePhrase_Proxy(IWordBreaker *This,const WCHAR *pwcNoun,ULONG cwcNoun,const WCHAR *pwcModifier,ULONG cwcModifier,ULONG ulAttachmentType,WCHAR *pwcPhrase,ULONG *pcwcPhrase);
  void __RPC_STUB IWordBreaker_ComposePhrase_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IWordBreaker_GetLicenseToUse_Proxy(IWordBreaker *This,const WCHAR **ppwcsLicense);
  void __RPC_STUB IWordBreaker_GetLicenseToUse_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
#endif

#ifndef __IWordFormSink_INTERFACE_DEFINED__
#define __IWordFormSink_INTERFACE_DEFINED__
  EXTERN_C const IID IID_IWordFormSink;
#if defined(__cplusplus) && !defined(CINTERFACE)
  struct IWordFormSink : public IUnknown {
  public:
    virtual HRESULT WINAPI PutAltWord(const WCHAR *pwcInBuf,ULONG cwc) = 0;
    virtual HRESULT WINAPI PutWord(const WCHAR *pwcInBuf,ULONG cwc) = 0;
  };
#else
  typedef struct IWordFormSinkVtbl {
    BEGIN_INTERFACE
      HRESULT (WINAPI *QueryInterface)(IWordFormSink *This,REFIID riid,void **ppvObject);
      ULONG (WINAPI *AddRef)(IWordFormSink *This);
      ULONG (WINAPI *Release)(IWordFormSink *This);
      HRESULT (WINAPI *PutAltWord)(IWordFormSink *This,const WCHAR *pwcInBuf,ULONG cwc);
      HRESULT (WINAPI *PutWord)(IWordFormSink *This,const WCHAR *pwcInBuf,ULONG cwc);
    END_INTERFACE
  } IWordFormSinkVtbl;
  struct IWordFormSink {
    CONST_VTBL struct IWordFormSinkVtbl *lpVtbl;
  };
#ifdef COBJMACROS
#define IWordFormSink_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define IWordFormSink_AddRef(This) (This)->lpVtbl->AddRef(This)
#define IWordFormSink_Release(This) (This)->lpVtbl->Release(This)
#define IWordFormSink_PutAltWord(This,pwcInBuf,cwc) (This)->lpVtbl->PutAltWord(This,pwcInBuf,cwc)
#define IWordFormSink_PutWord(This,pwcInBuf,cwc) (This)->lpVtbl->PutWord(This,pwcInBuf,cwc)
#endif
#endif
  HRESULT WINAPI IWordFormSink_PutAltWord_Proxy(IWordFormSink *This,const WCHAR *pwcInBuf,ULONG cwc);
  void __RPC_STUB IWordFormSink_PutAltWord_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IWordFormSink_PutWord_Proxy(IWordFormSink *This,const WCHAR *pwcInBuf,ULONG cwc);
  void __RPC_STUB IWordFormSink_PutWord_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
#endif

#ifndef __IStemmer_INTERFACE_DEFINED__
#define __IStemmer_INTERFACE_DEFINED__
  EXTERN_C const IID IID_IStemmer;
#if defined(__cplusplus) && !defined(CINTERFACE)
  struct IStemmer : public IUnknown {
  public:
    virtual HRESULT WINAPI Init(ULONG ulMaxTokenSize,WINBOOL *pfLicense) = 0;
    virtual HRESULT WINAPI GenerateWordForms(const WCHAR *pwcInBuf,ULONG cwc,IWordFormSink *pStemSink) = 0;
    virtual HRESULT WINAPI GetLicenseToUse(const WCHAR **ppwcsLicense) = 0;
  };
#else
  typedef struct IStemmerVtbl {
    BEGIN_INTERFACE
      HRESULT (WINAPI *QueryInterface)(IStemmer *This,REFIID riid,void **ppvObject);
      ULONG (WINAPI *AddRef)(IStemmer *This);
      ULONG (WINAPI *Release)(IStemmer *This);
      HRESULT (WINAPI *Init)(IStemmer *This,ULONG ulMaxTokenSize,WINBOOL *pfLicense);
      HRESULT (WINAPI *GenerateWordForms)(IStemmer *This,const WCHAR *pwcInBuf,ULONG cwc,IWordFormSink *pStemSink);
      HRESULT (WINAPI *GetLicenseToUse)(IStemmer *This,const WCHAR **ppwcsLicense);
    END_INTERFACE
  } IStemmerVtbl;
  struct IStemmer {
    CONST_VTBL struct IStemmerVtbl *lpVtbl;
  };
#ifdef COBJMACROS
#define IStemmer_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define IStemmer_AddRef(This) (This)->lpVtbl->AddRef(This)
#define IStemmer_Release(This) (This)->lpVtbl->Release(This)
#define IStemmer_Init(This,ulMaxTokenSize,pfLicense) (This)->lpVtbl->Init(This,ulMaxTokenSize,pfLicense)
#define IStemmer_GenerateWordForms(This,pwcInBuf,cwc,pStemSink) (This)->lpVtbl->GenerateWordForms(This,pwcInBuf,cwc,pStemSink)
#define IStemmer_GetLicenseToUse(This,ppwcsLicense) (This)->lpVtbl->GetLicenseToUse(This,ppwcsLicense)
#endif
#endif
  HRESULT WINAPI IStemmer_Init_Proxy(IStemmer *This,ULONG ulMaxTokenSize,WINBOOL *pfLicense);
  void __RPC_STUB IStemmer_Init_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IStemmer_GenerateWordForms_Proxy(IStemmer *This,const WCHAR *pwcInBuf,ULONG cwc,IWordFormSink *pStemSink);
  void __RPC_STUB IStemmer_GenerateWordForms_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IStemmer_GetLicenseToUse_Proxy(IStemmer *This,const WCHAR **ppwcsLicense);
  void __RPC_STUB IStemmer_GetLicenseToUse_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
#endif

  extern RPC_IF_HANDLE __MIDL_itf_indexsrv_0130_v0_0_c_ifspec;
  extern RPC_IF_HANDLE __MIDL_itf_indexsrv_0130_v0_0_s_ifspec;

#ifndef __ISimpleCommandCreator_INTERFACE_DEFINED__
#define __ISimpleCommandCreator_INTERFACE_DEFINED__
  EXTERN_C const IID IID_ISimpleCommandCreator;
#if defined(__cplusplus) && !defined(CINTERFACE)
  struct ISimpleCommandCreator : public IUnknown {
  public:
    virtual HRESULT WINAPI CreateICommand(IUnknown **ppIUnknown,IUnknown *pOuterUnk) = 0;
    virtual HRESULT WINAPI VerifyCatalog(const WCHAR *pwszMachine,const WCHAR *pwszCatalogName) = 0;
    virtual HRESULT WINAPI GetDefaultCatalog(WCHAR *pwszCatalogName,ULONG cwcIn,ULONG *pcwcOut) = 0;
  };
#else
  typedef struct ISimpleCommandCreatorVtbl {
    BEGIN_INTERFACE
      HRESULT (WINAPI *QueryInterface)(ISimpleCommandCreator *This,REFIID riid,void **ppvObject);
      ULONG (WINAPI *AddRef)(ISimpleCommandCreator *This);
      ULONG (WINAPI *Release)(ISimpleCommandCreator *This);
      HRESULT (WINAPI *CreateICommand)(ISimpleCommandCreator *This,IUnknown **ppIUnknown,IUnknown *pOuterUnk);
      HRESULT (WINAPI *VerifyCatalog)(ISimpleCommandCreator *This,const WCHAR *pwszMachine,const WCHAR *pwszCatalogName);
      HRESULT (WINAPI *GetDefaultCatalog)(ISimpleCommandCreator *This,WCHAR *pwszCatalogName,ULONG cwcIn,ULONG *pcwcOut);
    END_INTERFACE
  } ISimpleCommandCreatorVtbl;
  struct ISimpleCommandCreator {
    CONST_VTBL struct ISimpleCommandCreatorVtbl *lpVtbl;
  };
#ifdef COBJMACROS
#define ISimpleCommandCreator_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define ISimpleCommandCreator_AddRef(This) (This)->lpVtbl->AddRef(This)
#define ISimpleCommandCreator_Release(This) (This)->lpVtbl->Release(This)
#define ISimpleCommandCreator_CreateICommand(This,ppIUnknown,pOuterUnk) (This)->lpVtbl->CreateICommand(This,ppIUnknown,pOuterUnk)
#define ISimpleCommandCreator_VerifyCatalog(This,pwszMachine,pwszCatalogName) (This)->lpVtbl->VerifyCatalog(This,pwszMachine,pwszCatalogName)
#define ISimpleCommandCreator_GetDefaultCatalog(This,pwszCatalogName,cwcIn,pcwcOut) (This)->lpVtbl->GetDefaultCatalog(This,pwszCatalogName,cwcIn,pcwcOut)
#endif
#endif
  HRESULT WINAPI ISimpleCommandCreator_CreateICommand_Proxy(ISimpleCommandCreator *This,IUnknown **ppIUnknown,IUnknown *pOuterUnk);
  void __RPC_STUB ISimpleCommandCreator_CreateICommand_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI ISimpleCommandCreator_VerifyCatalog_Proxy(ISimpleCommandCreator *This,const WCHAR *pwszMachine,const WCHAR *pwszCatalogName);
  void __RPC_STUB ISimpleCommandCreator_VerifyCatalog_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI ISimpleCommandCreator_GetDefaultCatalog_Proxy(ISimpleCommandCreator *This,WCHAR *pwszCatalogName,ULONG cwcIn,ULONG *pcwcOut);
  void __RPC_STUB ISimpleCommandCreator_GetDefaultCatalog_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
#endif

#define CLSID_CISimpleCommandCreator {0xc7b6c04a,0xcbb5,0x11d0,{0xbb,0x4c,0x0,0xc0,0x4f,0xc2,0xf4,0x10 } }
  typedef struct tagDBID DBID;
  typedef WORD DBTYPE;

  extern RPC_IF_HANDLE __MIDL_itf_indexsrv_0131_v0_0_c_ifspec;
  extern RPC_IF_HANDLE __MIDL_itf_indexsrv_0131_v0_0_s_ifspec;

#ifndef __IColumnMapper_INTERFACE_DEFINED__
#define __IColumnMapper_INTERFACE_DEFINED__
  EXTERN_C const IID IID_IColumnMapper;
#if defined(__cplusplus) && !defined(CINTERFACE)
  struct IColumnMapper : public IUnknown {
  public:
    virtual HRESULT WINAPI GetPropInfoFromName(const WCHAR *wcsPropName,DBID **ppPropId,DBTYPE *pPropType,unsigned int *puiWidth) = 0;
    virtual HRESULT WINAPI GetPropInfoFromId(const DBID *pPropId,WCHAR **pwcsName,DBTYPE *pPropType,unsigned int *puiWidth) = 0;
    virtual HRESULT WINAPI EnumPropInfo(ULONG iEntry,const WCHAR **pwcsName,DBID **ppPropId,DBTYPE *pPropType,unsigned int *puiWidth) = 0;
    virtual HRESULT WINAPI IsMapUpToDate(void) = 0;
  };
#else
  typedef struct IColumnMapperVtbl {
    BEGIN_INTERFACE
      HRESULT (WINAPI *QueryInterface)(IColumnMapper *This,REFIID riid,void **ppvObject);
      ULONG (WINAPI *AddRef)(IColumnMapper *This);
      ULONG (WINAPI *Release)(IColumnMapper *This);
      HRESULT (WINAPI *GetPropInfoFromName)(IColumnMapper *This,const WCHAR *wcsPropName,DBID **ppPropId,DBTYPE *pPropType,unsigned int *puiWidth);
      HRESULT (WINAPI *GetPropInfoFromId)(IColumnMapper *This,const DBID *pPropId,WCHAR **pwcsName,DBTYPE *pPropType,unsigned int *puiWidth);
      HRESULT (WINAPI *EnumPropInfo)(IColumnMapper *This,ULONG iEntry,const WCHAR **pwcsName,DBID **ppPropId,DBTYPE *pPropType,unsigned int *puiWidth);
      HRESULT (WINAPI *IsMapUpToDate)(IColumnMapper *This);
    END_INTERFACE
  } IColumnMapperVtbl;
  struct IColumnMapper {
    CONST_VTBL struct IColumnMapperVtbl *lpVtbl;
  };
#ifdef COBJMACROS
#define IColumnMapper_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define IColumnMapper_AddRef(This) (This)->lpVtbl->AddRef(This)
#define IColumnMapper_Release(This) (This)->lpVtbl->Release(This)
#define IColumnMapper_GetPropInfoFromName(This,wcsPropName,ppPropId,pPropType,puiWidth) (This)->lpVtbl->GetPropInfoFromName(This,wcsPropName,ppPropId,pPropType,puiWidth)
#define IColumnMapper_GetPropInfoFromId(This,pPropId,pwcsName,pPropType,puiWidth) (This)->lpVtbl->GetPropInfoFromId(This,pPropId,pwcsName,pPropType,puiWidth)
#define IColumnMapper_EnumPropInfo(This,iEntry,pwcsName,ppPropId,pPropType,puiWidth) (This)->lpVtbl->EnumPropInfo(This,iEntry,pwcsName,ppPropId,pPropType,puiWidth)
#define IColumnMapper_IsMapUpToDate(This) (This)->lpVtbl->IsMapUpToDate(This)
#endif
#endif
  HRESULT WINAPI IColumnMapper_GetPropInfoFromName_Proxy(IColumnMapper *This,const WCHAR *wcsPropName,DBID **ppPropId,DBTYPE *pPropType,unsigned int *puiWidth);
  void __RPC_STUB IColumnMapper_GetPropInfoFromName_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IColumnMapper_GetPropInfoFromId_Proxy(IColumnMapper *This,const DBID *pPropId,WCHAR **pwcsName,DBTYPE *pPropType,unsigned int *puiWidth);
  void __RPC_STUB IColumnMapper_GetPropInfoFromId_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IColumnMapper_EnumPropInfo_Proxy(IColumnMapper *This,ULONG iEntry,const WCHAR **pwcsName,DBID **ppPropId,DBTYPE *pPropType,unsigned int *puiWidth);
  void __RPC_STUB IColumnMapper_EnumPropInfo_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
  HRESULT WINAPI IColumnMapper_IsMapUpToDate_Proxy(IColumnMapper *This);
  void __RPC_STUB IColumnMapper_IsMapUpToDate_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
#endif

#define LOCAL_MACHINE (L".")
#define SYSTEM_DEFAULT_CAT (L"__SystemDefault__")
#define INDEX_SERVER_DEFAULT_CAT (L"__IndexServerDefault__")

  extern RPC_IF_HANDLE __MIDL_itf_indexsrv_0132_v0_0_c_ifspec;
  extern RPC_IF_HANDLE __MIDL_itf_indexsrv_0132_v0_0_s_ifspec;

#ifndef __IColumnMapperCreator_INTERFACE_DEFINED__
#define __IColumnMapperCreator_INTERFACE_DEFINED__
  EXTERN_C const IID IID_IColumnMapperCreator;
#if defined(__cplusplus) && !defined(CINTERFACE)
  struct IColumnMapperCreator : public IUnknown {
  public:
    virtual HRESULT WINAPI GetColumnMapper(const WCHAR *wcsMachineName,const WCHAR *wcsCatalogName,IColumnMapper **ppColumnMapper) = 0;
  };
#else
  typedef struct IColumnMapperCreatorVtbl {
    BEGIN_INTERFACE
      HRESULT (WINAPI *QueryInterface)(IColumnMapperCreator *This,REFIID riid,void **ppvObject);
      ULONG (WINAPI *AddRef)(IColumnMapperCreator *This);
      ULONG (WINAPI *Release)(IColumnMapperCreator *This);
      HRESULT (WINAPI *GetColumnMapper)(IColumnMapperCreator *This,const WCHAR *wcsMachineName,const WCHAR *wcsCatalogName,IColumnMapper **ppColumnMapper);
    END_INTERFACE
  } IColumnMapperCreatorVtbl;
  struct IColumnMapperCreator {
    CONST_VTBL struct IColumnMapperCreatorVtbl *lpVtbl;
  };
#ifdef COBJMACROS
#define IColumnMapperCreator_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject)
#define IColumnMapperCreator_AddRef(This) (This)->lpVtbl->AddRef(This)
#define IColumnMapperCreator_Release(This) (This)->lpVtbl->Release(This)
#define IColumnMapperCreator_GetColumnMapper(This,wcsMachineName,wcsCatalogName,ppColumnMapper) (This)->lpVtbl->GetColumnMapper(This,wcsMachineName,wcsCatalogName,ppColumnMapper)
#endif
#endif
  HRESULT WINAPI IColumnMapperCreator_GetColumnMapper_Proxy(IColumnMapperCreator *This,const WCHAR *wcsMachineName,const WCHAR *wcsCatalogName,IColumnMapper **ppColumnMapper);
  void __RPC_STUB IColumnMapperCreator_GetColumnMapper_Stub(IRpcStubBuffer *This,IRpcChannelBuffer *_pRpcChannelBuffer,PRPC_MESSAGE _pRpcMessage,DWORD *_pdwStubPhase);
#endif

#ifdef __cplusplus
}
#endif
#endif


text:
package com.cody.handler.business.presenter;

import com.cody.handler.business.viewmodel.MainViewModel;
import com.cody.handler.framework.IView;
import com.cody.handler.framework.presenter.Presenter;

/**
 * Created by cody.yi on 2018/7/18.
 * 首页
 */
public class MainPresenter extends Presenter<MainViewModel> {

    public MainPresenter() {
    }

    @Override
    public void attachView(Object tag, IView view, MainViewModel viewModel) {
        super.attachView(tag, view, viewModel);
    }

    @Override
    public void detachView(Object tag) {
        super.detachView(tag);
    }
}

redpajama_set_name: RedPajamaGithub


text:
'use strict';

var EventListener;
var EventPluginHub;
var EventPluginRegistry;
var React;
var ReactDOM;
var ReactDOMComponentTree;
var ReactBrowserEventEmitter;
var ReactTestUtils;
var TapEventPlugin;

var tapMoveThreshold;
var idCallOrder;
var recordID = function(id) {
  idCallOrder.push(id);
};
var recordIDAndStopPropagation = function(id, event) {
  recordID(id);
  event.stopPropagation();
};
var recordIDAndReturnFalse = function(id, event) {
  recordID(id);
  return false;
};
var LISTENER = jest.fn();
var ON_CLICK_KEY = 'onClick';
var ON_TOUCH_TAP_KEY = 'onTouchTap';
var ON_CHANGE_KEY = 'onChange';
var ON_MOUSE_ENTER_KEY = 'onMouseEnter';

var GRANDPARENT;
var PARENT;
var CHILD;

var getListener;
var putListener;
var deleteAllListeners;

function registerSimpleTestHandler() {
  putListener(CHILD, ON_CLICK_KEY, LISTENER);
  var listener = getListener(CHILD, ON_CLICK_KEY);
  expect(listener).toEqual(LISTENER);
  return getListener(CHILD, ON_CLICK_KEY);
}

describe('ReactBrowserEventEmitter', () => {
  beforeEach(() => {
    jest.resetModules();
    LISTENER.mockClear();
    EventListener = require('fbjs/lib/EventListener');
    EventPluginHub = require('EventPluginHub');
    EventPluginRegistry = require('EventPluginRegistry');
    React = require('react');
    ReactDOM = require('react-dom');
    ReactDOMComponentTree = require('ReactDOMComponentTree');
    ReactBrowserEventEmitter = require('ReactBrowserEventEmitter');
    ReactTestUtils = require('ReactTestUtils');
    TapEventPlugin = require('TapEventPlugin');

    var container = document.createElement('div');

    var GRANDPARENT_PROPS = {};
    var PARENT_PROPS = {};
    var CHILD_PROPS = {};

    function Child(props) {
      return
 (CHILD = c)} {...props} />;
    }

    class ChildWrapper extends React.PureComponent {
      render() {
        return <Child {...this.props} />;
      }
    }

    function renderTree() {
      ReactDOM.render(

 (GRANDPARENT = c)} {...GRANDPARENT_PROPS}>

 (PARENT = c)} {...PARENT_PROPS}>
            <ChildWrapper {...CHILD_PROPS} />

,
        container,
      );
    }

    renderTree();

    getListener = function(node, eventName) {
      var inst = ReactDOMComponentTree.getInstanceFromNode(node);
      return EventPluginHub.getListener(inst, eventName);
    };
    putListener = function(node, eventName, listener) {
      switch (node) {
        case CHILD:
          CHILD_PROPS[eventName] = listener;
          break;
        case PARENT:
          PARENT_PROPS[eventName] = listener;
          break;
        case GRANDPARENT:
          GRANDPARENT_PROPS[eventName] = listener;
          break;
      }
      // Rerender with new event listeners
      renderTree();
    };
    deleteAllListeners = function(node) {
      switch (node) {
        case CHILD:
          CHILD_PROPS = {};
          break;
        case PARENT:
          PARENT_PROPS = {};
          break;
        case GRANDPARENT:
          GRANDPARENT_PROPS = {};
          break;
      }
      renderTree();
    };

    idCallOrder = [];
    tapMoveThreshold = TapEventPlugin.tapMoveThreshold;
    EventPluginHub.injection.injectEventPluginsByName({
      TapEventPlugin: TapEventPlugin,
    });
  });

  it('should store a listener correctly', () => {
    registerSimpleTestHandler();
    var listener = getListener(CHILD, ON_CLICK_KEY);
    expect(listener).toBe(LISTENER);
  });

  it('should retrieve a listener correctly', () => {
    registerSimpleTestHandler();
    var listener = getListener(CHILD, ON_CLICK_KEY);
    expect(listener).toEqual(LISTENER);
  });

  it('should clear all handlers when asked to', () => {
    registerSimpleTestHandler();
    deleteAllListeners(CHILD);
    var listener = getListener(CHILD, ON_CLICK_KEY);
    expect(listener).toBe(undefined);
  });

  it('should invoke a simple handler registered on a node', () => {
    registerSimpleTestHandler();
    ReactTestUtils.Simulate.click(CHILD);
    expect(LISTENER.mock.calls.length).toBe(1);
  });

  it('should not invoke handlers if ReactBrowserEventEmitter is disabled', () => {
    registerSimpleTestHandler();
    ReactBrowserEventEmitter.setEnabled(false);
    ReactTestUtils.SimulateNative.click(CHILD);
    expect(LISTENER.mock.calls.length).toBe(0);
    ReactBrowserEventEmitter.setEnabled(true);
    ReactTestUtils.SimulateNative.click(CHILD);
    expect(LISTENER.mock.calls.length).toBe(1);
  });

  it('should bubble simply', () => {
    putListener(CHILD, ON_CLICK_KEY, recordID.bind(null, CHILD));
    putListener(PARENT, ON_CLICK_KEY, recordID.bind(null, PARENT));
    putListener(GRANDPARENT, ON_CLICK_KEY, recordID.bind(null, GRANDPARENT));
    ReactTestUtils.Simulate.click(CHILD);
    expect(idCallOrder.length).toBe(3);
    expect(idCallOrder[0]).toBe(CHILD);
    expect(idCallOrder[1]).toBe(PARENT);
    expect(idCallOrder[2]).toBe(GRANDPARENT);
  });

  it('should bubble to the right handler after an update', () => {
    putListener(GRANDPARENT, ON_CLICK_KEY, recordID.bind(null, 'GRANDPARENT'));
    putListener(PARENT, ON_CLICK_KEY, recordID.bind(null, 'PARENT'));
    putListener(CHILD, ON_CLICK_KEY, recordID.bind(null, 'CHILD'));
    ReactTestUtils.Simulate.click(CHILD);
    expect(idCallOrder).toEqual(['CHILD', 'PARENT', 'GRANDPARENT']);

    idCallOrder = [];

    // Update just the grand parent without updating the child.
    putListener(
      GRANDPARENT,
      ON_CLICK_KEY,
      recordID.bind(null, 'UPDATED_GRANDPARENT'),
    );

    ReactTestUtils.Simulate.click(CHILD);
    expect(idCallOrder).toEqual(['CHILD', 'PARENT', 'UPDATED_GRANDPARENT']);
  });

  it('should continue bubbling if an error is thrown', () => {
    putListener(CHILD, ON_CLICK_KEY, recordID.bind(null, CHILD));
    putListener(PARENT, ON_CLICK_KEY, function() {
      recordID(PARENT);
      throw new Error('Handler interrupted');
    });
    putListener(GRANDPARENT, ON_CLICK_KEY, recordID.bind(null, GRANDPARENT));
    expect(function() {
      ReactTestUtils.Simulate.click(CHILD);
    }).toThrow();
    expect(idCallOrder.length).toBe(3);
    expect(idCallOrder[0]).toBe(CHILD);
    expect(idCallOrder[1]).toBe(PARENT);
    expect(idCallOrder[2]).toBe(GRANDPARENT);
  });

  it('should set currentTarget', () => {
    putListener(CHILD, ON_CLICK_KEY, function(event) {
      recordID(CHILD);
      expect(event.currentTarget).toBe(CHILD);
    });
    putListener(PARENT, ON_CLICK_KEY, function(event) {
      recordID(PARENT);
      expect(event.currentTarget).toBe(PARENT);
    });
    putListener(GRANDPARENT, ON_CLICK_KEY, function(event) {
      recordID(GRANDPARENT);
      expect(event.currentTarget).toBe(GRANDPARENT);
    });
    ReactTestUtils.Simulate.click(CHILD);
    expect(idCallOrder.length).toBe(3);
    expect(idCallOrder[0]).toBe(CHILD);
    expect(idCallOrder[1]).toBe(PARENT);
    expect(idCallOrder[2]).toBe(GRANDPARENT);
  });

  it('should support stopPropagation()', () => {
    putListener(CHILD, ON_CLICK_KEY, recordID.bind(null, CHILD));
    putListener(
      PARENT,
      ON_CLICK_KEY,
      recordIDAndStopPropagation.bind(null, PARENT),
    );
    putListener(GRANDPARENT, ON_CLICK_KEY, recordID.bind(null, GRANDPARENT));
    ReactTestUtils.Simulate.click(CHILD);
    expect(idCallOrder.length).toBe(2);
    expect(idCallOrder[0]).toBe(CHILD);
    expect(idCallOrder[1]).toBe(PARENT);
  });

  it('should support overriding .isPropagationStopped()', () => {
    // Ew. See D4504876.
    putListener(CHILD, ON_CLICK_KEY, recordID.bind(null, CHILD));
    putListener(PARENT, ON_CLICK_KEY, function(e) {
      recordID(PARENT, e);
      // This stops React bubbling but avoids touching the native event
      e.isPropagationStopped = () => true;
    });
    putListener(GRANDPARENT, ON_CLICK_KEY, recordID.bind(null, GRANDPARENT));
    ReactTestUtils.Simulate.click(CHILD);
    expect(idCallOrder.length).toBe(2);
    expect(idCallOrder[0]).toBe(CHILD);
    expect(idCallOrder[1]).toBe(PARENT);
  });

  it('should stop after first dispatch if stopPropagation', () => {
    putListener(
      CHILD,
      ON_CLICK_KEY,
      recordIDAndStopPropagation.bind(null, CHILD),
    );
    putListener(PARENT, ON_CLICK_KEY, recordID.bind(null, PARENT));
    putListener(GRANDPARENT, ON_CLICK_KEY, recordID.bind(null, GRANDPARENT));
    ReactTestUtils.Simulate.click(CHILD);
    expect(idCallOrder.length).toBe(1);
    expect(idCallOrder[0]).toBe(CHILD);
  });

  it('should not stopPropagation if false is returned', () => {
    putListener(CHILD, ON_CLICK_KEY, recordIDAndReturnFalse.bind(null, CHILD));
    putListener(PARENT, ON_CLICK_KEY, recordID.bind(null, PARENT));
    putListener(GRANDPARENT, ON_CLICK_KEY, recordID.bind(null, GRANDPARENT));
    spyOn(console, 'error');
    ReactTestUtils.Simulate.click(CHILD);
    expect(idCallOrder.length).toBe(3);
    expect(idCallOrder[0]).toBe(CHILD);
    expect(idCallOrder[1]).toBe(PARENT);
    expect(idCallOrder[2]).toBe(GRANDPARENT);
    expectDev(console.error.calls.count()).toEqual(0);
  });

  /**
   * The entire event registration state of the world should be "locked-in" at
   * the time the event occurs. This is to resolve many edge cases that come
   * about from a listener on a lower-in-DOM node causing structural changes at
   * places higher in the DOM. If this lower-in-DOM node causes new content to
   * be rendered at a place higher-in-DOM, we need to be careful not to invoke
   * these new listeners.
   */

  it('should invoke handlers that were removed while bubbling', () => {
    var handleParentClick = jest.fn();
    var handleChildClick = function(event) {
      deleteAllListeners(PARENT);
    };
    putListener(CHILD, ON_CLICK_KEY, handleChildClick);
    putListener(PARENT, ON_CLICK_KEY, handleParentClick);
    ReactTestUtils.Simulate.click(CHILD);
    expect(handleParentClick.mock.calls.length).toBe(1);
  });

  it('should not invoke newly inserted handlers while bubbling', () => {
    var handleParentClick = jest.fn();
    var handleChildClick = function(event) {
      putListener(PARENT, ON_CLICK_KEY, handleParentClick);
    };
    putListener(CHILD, ON_CLICK_KEY, handleChildClick);
    ReactTestUtils.Simulate.click(CHILD);
    expect(handleParentClick.mock.calls.length).toBe(0);
  });

  it('should have mouse enter simulated by test utils', () => {
    putListener(CHILD, ON_MOUSE_ENTER_KEY, recordID.bind(null, CHILD));
    ReactTestUtils.Simulate.mouseEnter(CHILD);
    expect(idCallOrder.length).toBe(1);
    expect(idCallOrder[0]).toBe(CHILD);
  });

  it('should infer onTouchTap from a touchStart/End', () => {
    putListener(CHILD, ON_TOUCH_TAP_KEY, recordID.bind(null, CHILD));
    ReactTestUtils.SimulateNative.touchStart(
      CHILD,
      ReactTestUtils.nativeTouchData(0, 0),
    );
    ReactTestUtils.SimulateNative.touchEnd(
      CHILD,
      ReactTestUtils.nativeTouchData(0, 0),
    );
    expect(idCallOrder.length).toBe(1);
    expect(idCallOrder[0]).toBe(CHILD);
  });

  it('should infer onTouchTap from when dragging below threshold', () => {
    putListener(CHILD, ON_TOUCH_TAP_KEY, recordID.bind(null, CHILD));
    ReactTestUtils.SimulateNative.touchStart(
      CHILD,
      ReactTestUtils.nativeTouchData(0, 0),
    );
    ReactTestUtils.SimulateNative.touchEnd(
      CHILD,
      ReactTestUtils.nativeTouchData(0, tapMoveThreshold - 1),
    );
    expect(idCallOrder.length).toBe(1);
    expect(idCallOrder[0]).toBe(CHILD);
  });

  it('should not onTouchTap from when dragging beyond threshold', () => {
    putListener(CHILD, ON_TOUCH_TAP_KEY, recordID.bind(null, CHILD));
    ReactTestUtils.SimulateNative.touchStart(
      CHILD,
      ReactTestUtils.nativeTouchData(0, 0),
    );
    ReactTestUtils.SimulateNative.touchEnd(
      CHILD,
      ReactTestUtils.nativeTouchData(0, tapMoveThreshold + 1),
    );
    expect(idCallOrder.length).toBe(0);
  });

  it('should listen to events only once', () => {
    spyOn(EventListener, 'listen');
    ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
    ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);
    expect(EventListener.listen.calls.count()).toBe(1);
  });

  it('should work with event plugins without dependencies', () => {
    spyOn(EventListener, 'listen');

    ReactBrowserEventEmitter.listenTo(ON_CLICK_KEY, document);

    expect(EventListener.listen.calls.argsFor(0)[1]).toBe('click');
  });

  it('should work with event plugins with dependencies', () => {
    spyOn(EventListener, 'listen');
    spyOn(EventListener, 'capture');

    ReactBrowserEventEmitter.listenTo(ON_CHANGE_KEY, document);

    var setEventListeners = [];
    var listenCalls = EventListener.listen.calls.allArgs();
    var captureCalls = EventListener.capture.calls.allArgs();
    for (var i = 0; i < listenCalls.length; i++) {
      setEventListeners.push(listenCalls[i][1]);
    }
    for (i = 0; i < captureCalls.length; i++) {
      setEventListeners.push(captureCalls[i][1]);
    }

    var module = EventPluginRegistry.registrationNameModules[ON_CHANGE_KEY];
    var dependencies = module.eventTypes.change.dependencies;
    expect(setEventListeners.length).toEqual(dependencies.length);

    for (i = 0; i < setEventListeners.length; i++) {
      expect(dependencies.indexOf(setEventListeners[i])).toBeTruthy();
    }
  });

  it('should bubble onTouchTap', () => {
    putListener(CHILD, ON_TOUCH_TAP_KEY, recordID.bind(null, CHILD));
    putListener(PARENT, ON_TOUCH_TAP_KEY, recordID.bind(null, PARENT));
    putListener(
      GRANDPARENT,
      ON_TOUCH_TAP_KEY,
      recordID.bind(null, GRANDPARENT),
    );
    ReactTestUtils.SimulateNative.touchStart(
      CHILD,
      ReactTestUtils.nativeTouchData(0, 0),
    );
    ReactTestUtils.SimulateNative.touchEnd(
      CHILD,
      ReactTestUtils.nativeTouchData(0, 0),
    );
    expect(idCallOrder.length).toBe(3);
    expect(idCallOrder[0] === CHILD).toBe(true);
    expect(idCallOrder[1] === PARENT).toBe(true);
    expect(idCallOrder[2] === GRANDPARENT).toBe(true);
  });
});


text:
module.exports = (sequelize, DataTypes) => {
  const lendItem = sequelize.define('lendItem', {
    name: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    description: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    available: {
      type: DataTypes.BOOLEAN,
      defaultValue: false,
    },
    viewCount: {
      type: DataTypes.INTEGER,
      defaultValue: 0,
    },
  });

  lendItem.associate = (models) => {
    lendItem.belongsTo(models.userSchema);

    lendItem.hasMany(models.imageSchema, {
      foreignKey: 'lendItemId',
      sourceKey: 'id',
    });

    lendItem.hasMany(models.bookmarkSchema, {
      foreignKey: 'lendItemId',
      sourceKey: 'id',
    });
  };

  return lendItem;
};


text:
package org.apache.nifi.web.api.entity;

import io.swagger.annotations.ApiModelProperty;
import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.dto.VersionedFlowUpdateRequestDTO;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "versionedFlowUpdateRequestEntity")
public class VersionedFlowUpdateRequestEntity extends Entity {
    private VersionedFlowUpdateRequestDTO request;
    private RevisionDTO processGroupRevision;

    @ApiModelProperty("The revision for the Process Group that owns this variable registry.")
    public RevisionDTO getProcessGroupRevision() {
        return processGroupRevision;
    }

    public void setProcessGroupRevision(RevisionDTO revision) {
        this.processGroupRevision = revision;
    }

    @ApiModelProperty("The Versioned Flow Update Request")
    public VersionedFlowUpdateRequestDTO getRequest() {
        return request;
    }

    public void setRequest(VersionedFlowUpdateRequestDTO request) {
        this.request = request;
    }

}


text:
<!doctype html>

		<meta charset="utf-8">

		<title>Dnote Pitch</title>

		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />

		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">

		<link rel="stylesheet" href="css/reveal.css">
		<link rel="stylesheet" href="css/theme/white.css" id="theme">
		<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">

		<link rel="stylesheet" href="lib/css/zenburn.css">

Dnote

Developer Notebook

							Sung Won Cho / @mikeswcho

							Presented April 21 at Fishburners

Problem

							Developers forget what they learn

Note != Solution

Context switching

No reinforcement

Solution

							A note program in your terminal

No context switching

Book

Note

dnote use

dnote new

dnote notes

dnote sync

Reinforcement

							Email digest (premium)

Making

3 hours. 200 lines.

Only on free time

Shipped 4 weeks ago

Open source - MIT

Traction

> 800 execution/day

> 7000 website visitors

> 200 GitHub stars

$0 marketing

April goals

Landing page

10 active users

Web client

Email feature

Sale

Sung

								sung.io

								@mikeswcho

Don't Learn More. Forget Less.

dnote.io


text:
using namespace OC;
namespace PH = std::placeholders;

// Option ID for API version and client token
const uint16_t API_VERSION = 2048;
const uint16_t TOKEN = 3000;

// Setting API version and token (shared out of band with client)
// This assumes the fact that this server responds
// only with a server with below version and token
const std::string FRIDGE_CLIENT_API_VERSION = "v.1.0";
const std::string FRIDGE_CLIENT_TOKEN = "21ae43gf";

// Set of strings for each of platform Info fields
std::string  platformId = "0A3E0D6F-DBF5-404E-8719-D6880042463A";
std::string  manufacturerName = "OCF";
std::string  manufacturerLink = "https://www.iotivity.org";
std::string  modelNumber = "myModelNumber";
std::string  dateOfManufacture = "2016-01-15";
std::string  platformVersion = "myPlatformVersion";
std::string  operatingSystemVersion = "myOS";
std::string  hardwareVersion = "myHardwareVersion";
std::string  firmwareVersion = "1.0";
std::string  supportLink = "https://www.iotivity.org";
std::string  systemTime = "2016-01-15T11.01";

// Set of strings for each of device info fields
std::string  deviceName = "IoTivity Fridge Server";
std::string  specVersion = "ocf.1.1.0";
std::vector<std::string> dataModelVersions = {"ocf.res.1.1.0"};
std::string  protocolIndependentID = "054718eb-b1e7-4e9e-9892-30e718a6a8f3";

// OCPlatformInfo Contains all the platform info to be stored
OCPlatformInfo platformInfo;

class Resource
{
    protected:
    OCResourceHandle m_resourceHandle;
    OCRepresentation m_rep;
    virtual OCEntityHandlerResult entityHandler(std::shared_ptr<OCResourceRequest> request)=0;
};

class DeviceResource : public Resource
{
    public:

    DeviceResource():m_modelName{}
    {
        std::string resourceURI = "/device";
        std::string resourceTypeName = "intel.fridge";
        std::string resourceInterface = DEFAULT_INTERFACE;
        EntityHandler cb = std::bind(&DeviceResource::entityHandler, this,PH::_1);

        EntityHandler defaultEH = std::bind(&DeviceResource::defaultEntityHandler
                                            ,this, PH::_1);

        std::cout << "Setting device default entity handler\n";
        OCPlatform::setDefaultDeviceEntityHandler(defaultEH);

        uint8_t resourceProperty = OC_DISCOVERABLE;
        OCStackResult result = OCPlatform::registerResource(m_resourceHandle,
            resourceURI,
            resourceTypeName,
            resourceInterface,
            cb,
            resourceProperty);

        if(OC_STACK_OK != result)
        {
            throw std::runtime_error(
                std::string("Device Resource failed to start")+std::to_string(result));
        }
    }
    private:
    OCRepresentation get()
    {
        m_rep.setValue("device_name", std::string("Intel Powered 2 door, 1 light refrigerator"));
        return m_rep;
    }

    OCStackResult deleteDeviceResource()
    {
        OCStackResult result = OCPlatform::unregisterResource(m_resourceHandle);
        if(OC_STACK_OK != result)
        {
            throw std::runtime_error(
               std::string("Device Resource failed to unregister/delete") + std::to_string(result));
        }
        return result;
    }

    std::string m_modelName;
    protected:
    virtual OCEntityHandlerResult entityHandler(std::shared_ptr<OCResourceRequest> request)
    {
        OCEntityHandlerResult ehResult = OC_EH_ERROR;
        if(request)
        {
            if(request->getRequestHandlerFlag() == RequestHandlerFlag::RequestFlag)
            {
                auto pResponse = std::make_shared<OC::OCResourceResponse>();
                pResponse->setRequestHandle(request->getRequestHandle());
                pResponse->setResourceHandle(request->getResourceHandle());

                if(request->getRequestType() == "GET")
                {
                    std::cout<<"DeviceResource Get Request"<<std::endl;

                    pResponse->setResponseResult(OC_EH_OK);
                    pResponse->setResourceRepresentation(get(), "");
                    if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
                    {
                        ehResult = OC_EH_OK;
                    }
                }
                else if(request->getRequestType() == "DELETE")
                {
                    std::cout<<"DeviceResource Delete Request"<<std::endl;
                    if(deleteDeviceResource() == OC_STACK_OK)
                    {

                        pResponse->setResponseResult(OC_EH_RESOURCE_DELETED);
                        ehResult = OC_EH_OK;
                    }
                    else
                    {
                        pResponse->setResponseResult(OC_EH_ERROR);
                        ehResult = OC_EH_ERROR;
                    }
                    OCPlatform::sendResponse(pResponse);
                }
                else
                {
                    std::cout <<"DeviceResource unsupported request type "
                    << request->getRequestType() << std::endl;
                    pResponse->setResponseResult(OC_EH_ERROR);
                    OCPlatform::sendResponse(pResponse);
                    ehResult = OC_EH_ERROR;
                }
            }
            else
            {
                std::cout << "DeviceResource unsupported request flag" <<std::endl;
            }
        }

        return ehResult;
    }

    virtual OCEntityHandlerResult defaultEntityHandler(std::shared_ptr<OCResourceRequest> request)
    {
        OCEntityHandlerResult ehResult = OC_EH_ERROR;
        if(request)
        {
            std::cout << "In Default Entity Handler, uri received: "
                        << request->getResourceUri() << std::endl;

            if(request->getRequestHandlerFlag() == RequestHandlerFlag::RequestFlag)
            {
                auto pResponse = std::make_shared<OC::OCResourceResponse>();
                pResponse->setRequestHandle(request->getRequestHandle());
                pResponse->setResourceHandle(request->getResourceHandle());

                if(request->getRequestType() == "GET")
                {
                    std::cout<<"Default Entity Handler: Get Request"<<std::endl;

                    pResponse->setResourceRepresentation(get(), "");
                    if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
                    {
                        ehResult = OC_EH_OK;
                    }
                }
                else
                {
                    std::cout <<"Default Entity Handler: unsupported request type "
                    << request->getRequestType() << std::endl;
                    pResponse->setResponseResult(OC_EH_ERROR);
                    OCPlatform::sendResponse(pResponse);
                    ehResult = OC_EH_ERROR;
                }
            }
            else
            {
                std::cout << "Default Entity Handler: unsupported request flag" <<std::endl;
            }
        }

        return ehResult;
   }

};

class LightResource : public Resource
{
    public:
    LightResource() : m_isOn(false)
    {
        std::string resourceURI = "/light";
        std::string resourceTypeName = "intel.fridge.light";
        std::string resourceInterface = DEFAULT_INTERFACE;
        EntityHandler cb = std::bind(&LightResource::entityHandler, this,PH::_1);
        uint8_t resourceProperty = 0;
        OCStackResult result = OCPlatform::registerResource(m_resourceHandle,
            resourceURI,
            resourceTypeName,
            resourceInterface,
            cb,
            resourceProperty);

        if(OC_STACK_OK != result)
        {
            throw std::runtime_error(
                std::string("Light Resource failed to start")+std::to_string(result));
        }
    }
    private:
    OCRepresentation get()
    {
        m_rep.setValue("on", m_isOn);
        return m_rep;
    }

    void put(const OCRepresentation& rep)
    {
        rep.getValue("on", m_isOn);
    }

    bool m_isOn;
    protected:
    virtual OCEntityHandlerResult entityHandler(std::shared_ptr<OCResourceRequest> request)
    {
        OCEntityHandlerResult ehResult = OC_EH_ERROR;
        if(request)
        {
            std::cout << "In entity handler for Light, URI is : "
                      << request->getResourceUri() << std::endl;

            if(request->getRequestHandlerFlag() == RequestHandlerFlag::RequestFlag)
            {
                auto pResponse = std::make_shared<OC::OCResourceResponse>();
                pResponse->setRequestHandle(request->getRequestHandle());
                pResponse->setResourceHandle(request->getResourceHandle());

                if(request->getRequestType() == "GET")
                {
                    std::cout<<"Light Get Request"<<std::endl;

                    pResponse->setResourceRepresentation(get(), "");
                    if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
                    {
                        ehResult = OC_EH_OK;
                    }
                }
                else if(request->getRequestType() == "PUT")
                {
                    std::cout <<"Light Put Request"<<std::endl;
                    put(request->getResourceRepresentation());

                    pResponse->setResourceRepresentation(get(), "");
                    if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
                    {
                        ehResult = OC_EH_OK;
                    }
                }
                else
                {
                    std::cout << "Light unsupported request type"
                    << request->getRequestType() << std::endl;
                    pResponse->setResponseResult(OC_EH_ERROR);
                    OCPlatform::sendResponse(pResponse);
                    ehResult = OC_EH_ERROR;
                }
            }
            else
            {
                std::cout << "Light unsupported request flag" <<std::endl;
            }
        }

        return ehResult;
    }
};

class DoorResource : public Resource
{
    public:
    DoorResource(const std::string& side):m_isOpen{false}, m_side(side)
    {

        std::string resourceURI = "/door/"+ side;
        std::string resourceTypeName = "intel.fridge.door";
        std::string resourceInterface = DEFAULT_INTERFACE;
        EntityHandler cb = std::bind(&DoorResource::entityHandler, this,PH::_1);

        uint8_t resourceProperty = 0;
        OCStackResult result = OCPlatform::registerResource(m_resourceHandle,
            resourceURI,
            resourceTypeName,
            resourceInterface,
            cb,
            resourceProperty);

        if(OC_STACK_OK != result)
        {
            throw std::runtime_error(
                std::string("Door Resource failed to start")+std::to_string(result));
        }
    }

    private:
    OCRepresentation get()
    {
        m_rep.setValue("open", m_isOpen);
        m_rep.setValue("side", m_side);
        return m_rep;
    }

    void put(const OCRepresentation& rep)
    {
        rep.getValue("open", m_isOpen);
        // Note, we won't let the user change the door side!
    }
    bool m_isOpen;
    std::string m_side;
    protected:
    virtual OCEntityHandlerResult entityHandler(std::shared_ptr<OCResourceRequest> request)
    {
        std::cout << "EH of door invoked " << std::endl;
        OCEntityHandlerResult ehResult = OC_EH_ERROR;

        if(request)
        {
            std::cout << "In entity handler for Door, URI is : "
                      << request->getResourceUri() << std::endl;

            if(request->getRequestHandlerFlag() == RequestHandlerFlag::RequestFlag)
            {
                auto pResponse = std::make_shared<OC::OCResourceResponse>();
                pResponse->setRequestHandle(request->getRequestHandle());
                pResponse->setResourceHandle(request->getResourceHandle());

                if(request->getRequestType() == "GET")
                {
                    // note that we know the side because std::bind gives us the
                    // appropriate object
                    std::cout<< m_side << " Door Get Request"<<std::endl;

                    pResponse->setResourceRepresentation(get(), "");
                    if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
                    {
                        ehResult = OC_EH_OK;
                    }
                }
                else if(request->getRequestType() == "PUT")
                {
                    std::cout << m_side <<" Door Put Request"<<std::endl;
                    put(request->getResourceRepresentation());

                    pResponse->setResourceRepresentation(get(),"");
                    if(OC_STACK_OK == OCPlatform::sendResponse(pResponse))
                    {
                        ehResult = OC_EH_OK;
                    }
                }
                else
                {
                    std::cout <<m_side<<" Door unsupported request type "
                    << request->getRequestType() << std::endl;
                    pResponse->setResponseResult(OC_EH_ERROR);
                    OCPlatform::sendResponse(pResponse);
                    ehResult = OC_EH_ERROR;
                }
            }
            else
            {
                std::cout << "Door unsupported request flag" <<std::endl;
            }
        }

        return ehResult;
    }

};

class Refrigerator
{
    public:
    Refrigerator()
        :
        m_light(),
        m_device(),
        m_leftdoor("left"),
        m_rightdoor("right")
    {
    }
    private:
    LightResource m_light;
    DeviceResource m_device;
    DoorResource m_leftdoor;
    DoorResource m_rightdoor;
};

void DeletePlatformInfo()
{
    delete[] platformInfo.platformID;
    delete[] platformInfo.manufacturerName;
    delete[] platformInfo.manufacturerUrl;
    delete[] platformInfo.modelNumber;
    delete[] platformInfo.dateOfManufacture;
    delete[] platformInfo.platformVersion;
    delete[] platformInfo.operatingSystemVersion;
    delete[] platformInfo.hardwareVersion;
    delete[] platformInfo.firmwareVersion;
    delete[] platformInfo.supportUrl;
    delete[] platformInfo.systemTime;
}

void DuplicateString(char ** targetString, std::string sourceString)
{
    *targetString = new char[sourceString.length() + 1];
    strncpy(*targetString, sourceString.c_str(), (sourceString.length() + 1));
}

OCStackResult SetPlatformInfo(std::string platformID, std::string manufacturerName,
    std::string manufacturerUrl, std::string modelNumber, std::string dateOfManufacture,
    std::string platformVersion, std::string operatingSystemVersion, std::string hardwareVersion,
    std::string firmwareVersion, std::string supportUrl, std::string systemTime)
{
    DuplicateString(&platformInfo.platformID, platformID);
    DuplicateString(&platformInfo.manufacturerName, manufacturerName);
    DuplicateString(&platformInfo.manufacturerUrl, manufacturerUrl);
    DuplicateString(&platformInfo.modelNumber, modelNumber);
    DuplicateString(&platformInfo.dateOfManufacture, dateOfManufacture);
    DuplicateString(&platformInfo.platformVersion, platformVersion);
    DuplicateString(&platformInfo.operatingSystemVersion, operatingSystemVersion);
    DuplicateString(&platformInfo.hardwareVersion, hardwareVersion);
    DuplicateString(&platformInfo.firmwareVersion, firmwareVersion);
    DuplicateString(&platformInfo.supportUrl, supportUrl);
    DuplicateString(&platformInfo.systemTime, systemTime);

    return OC_STACK_OK;
}

OCStackResult SetDeviceInfo()
{
    OCStackResult result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DEVICE_NAME,
                                                        deviceName);
    if (result != OC_STACK_OK)
    {
        std::cout << "Failed to set device name" << std::endl;
        return result;
    }

    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_DATA_MODEL_VERSION,
                                          dataModelVersions);
    if (result != OC_STACK_OK)
    {
        std::cout << "Failed to set data model versions" << std::endl;
        return result;
    }

    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_SPEC_VERSION, specVersion);
    if (result != OC_STACK_OK)
    {
        std::cout << "Failed to set spec version" << std::endl;
        return result;
    }

    result = OCPlatform::setPropertyValue(PAYLOAD_TYPE_DEVICE, OC_RSRVD_PROTOCOL_INDEPENDENT_ID,
                                          protocolIndependentID);
    if (result != OC_STACK_OK)
    {
        std::cout << "Failed to set piid" << std::endl;
        return result;
    }

    return OC_STACK_OK;
}

int main ()
{
    PlatformConfig cfg
    {
        ServiceType::InProc,
        ModeType::Server,
        nullptr
    };

    OCPlatform::Configure(cfg);
    OC_VERIFY(OCPlatform::start() == OC_STACK_OK);
    Refrigerator rf;

    std::cout << "Starting server & setting platform info\n";

    OCStackResult result = SetPlatformInfo(platformId, manufacturerName, manufacturerLink,
            modelNumber, dateOfManufacture, platformVersion, operatingSystemVersion,
            hardwareVersion, firmwareVersion, supportLink, systemTime);

    result = OCPlatform::registerPlatformInfo(platformInfo);

    if (result != OC_STACK_OK)
    {
        std::cout << "Platform Registration failed\n";
        return -1;
    }

    result = SetDeviceInfo();

    if (result != OC_STACK_OK)
    {
        std::cout << "Device Registration failed\n";
        return -1;
    }

    DeletePlatformInfo();
    // we will keep the server alive for at most 30 minutes
    std::this_thread::sleep_for(std::chrono::minutes(30));
    OC_VERIFY(OCPlatform::stop() == OC_STACK_OK);
    return 0;
}


text:
import {
  createCustomEvent,
  isLoaded,
  listen,
  listenOnce,
  listenOncePromise,
  loadPromise,
} from '../../src/event-helper';
import {Observable} from '../../src/observable';
import * as sinon from 'sinon';

describe('EventHelper', () => {

  function getEvent(name, target) {
    const event = document.createEvent('Event');
    event.initEvent(name, true, true);
    event.testTarget = target;
    return event;
  }

  let sandbox;
  let element;
  let loadObservable;
  let errorObservable;

  beforeEach(() => {
    sandbox = sinon.sandbox.create();
    loadObservable = new Observable();
    errorObservable = new Observable();
    element = {
      tagName: 'TEST',
      complete: false,
      readyState: '',
      addEventListener(type, callback) {
        if (type == 'load') {
          loadObservable.add(callback);
        } else if (type == 'error') {
          errorObservable.add(callback);
        } else {
          expect(type).to.equal('load or error');
        }
      },
      removeEventListener(type, callback) {
        if (type == 'load') {
          loadObservable.remove(callback);
        } else if (type == 'error') {
          errorObservable.remove(callback);
        } else {
          expect(type).to.equal('load or error');
        }
      },
    };
  });

  afterEach(() => {
    // Very important that all listeners are removed.
    expect(loadObservable.getHandlerCount()).to.equal(0);
    expect(errorObservable.getHandlerCount()).to.equal(0);

    sandbox.restore();
  });

  it('listen', () => {
    const event = getEvent('load', element);
    let c = 0;
    const handler = e => {
      c++;
      expect(e).to.equal(event);
    };
    const unlisten = listen(element, 'load', handler);

    // Not fired yet.
    expect(c).to.equal(0);

    // Fired once.
    loadObservable.fire(event);
    expect(c).to.equal(1);

    // Fired second time.
    loadObservable.fire(event);
    expect(c).to.equal(2);

    unlisten();
    loadObservable.fire(event);
    expect(c).to.equal(2);
  });

  it('listenOnce', () => {
    const event = getEvent('load', element);
    let c = 0;
    const handler = e => {
      c++;
      expect(e).to.equal(event);
    };
    listenOnce(element, 'load', handler);

    // Not fired yet.
    expect(c).to.equal(0);

    // Fired once.
    loadObservable.fire(event);
    expect(c).to.equal(1);

    // Fired second time: no longer listening.
    loadObservable.fire(event);
    expect(c).to.equal(1);
  });

  it('listenOnce - cancel', () => {
    const event = getEvent('load', element);
    let c = 0;
    const handler = e => {
      c++;
      expect(e).to.equal(event);
    };
    const unlisten = listenOnce(element, 'load', handler);

    // Not fired yet.
    expect(c).to.equal(0);

    // Cancel.
    unlisten();

    // Fired once: no longer listening.
    loadObservable.fire(event);
    expect(c).to.equal(0);
  });

  it('listenOncePromise - load event', () => {
    const event = getEvent('load', element);
    const promise = listenOncePromise(element, 'load').then(result => {
      expect(result).to.equal(event);
    });
    loadObservable.fire(event);
    return promise;
  });

  it('isLoaded for complete property', () => {
    expect(isLoaded(element)).to.equal(false);
    element.complete = true;
    expect(isLoaded(element)).to.equal(true);
  });

  it('isLoaded for readyState property', () => {
    expect(isLoaded(element)).to.equal(false);
    element.readyState = 'complete';
    expect(isLoaded(element)).to.equal(true);
  });

  it('isLoaded for Window', () => {
    expect(isLoaded(window)).to.equal(true);
    const win = {
      document: {
        readyState: 'interactive',
      },
    };
    expect(isLoaded(win)).to.equal(false);
    win.document.readyState = 'complete';
    expect(isLoaded(win)).to.equal(true);
  });

  it('loadPromise - already complete', () => {
    element.complete = true;
    return loadPromise(element).then(result => {
      expect(result).to.equal(element);
    });
  });

  it('loadPromise - already readyState == complete', () => {
    element.readyState = 'complete';
    return loadPromise(element).then(result => {
      expect(result).to.equal(element);
    });
  });

  it('loadPromise - load event', () => {
    const promise = loadPromise(element).then(result => {
      expect(result).to.equal(element);
    });
    loadObservable.fire(getEvent('load', element));
    return promise;
  });

  it('loadPromise - error event', () => {
    const promise = loadPromise(element).then(result => {
      assert.fail('must never be here: ' + result);
    }).then(() => {
      throw new Error('Should not be reached.');
    }, reason => {
      expect(reason.message).to.include('Failed to load');
    });
    errorObservable.fire(getEvent('error', element));
    return promise;
  });

  it('should polyfill CustomEvent constructor', () => {
    const native = createCustomEvent(window, 'foo', {bar: 123},
        {bubbles: true, cancelable: true});
    expect(native.type).to.equal('foo');
    expect(native.detail).to.deep.equal({bar: 123});
    expect(native.bubbles).to.be.true;
    expect(native.cancelable).to.be.true;

    const polyfilled = createCustomEvent({document}, 'foo', {bar: 123},
        {bubbles: true, cancelable: true});
    expect(polyfilled.type).to.equal('foo');
    expect(polyfilled.detail).to.deep.equal({bar: 123});
    expect(polyfilled.bubbles).to.be.true;
    expect(polyfilled.cancelable).to.be.true;
  });

  it('should create the correct custom event for IE11', () => {
    const native = createCustomEvent(window, 'foo', {bar: 123});
    expect(native.type).to.equal('foo');
    expect(native.detail).to.deep.equal({bar: 123});

    const initCustomEventSpy = sandbox.spy();
    const win = {};
    win.CustomEvent = {};
    win.document = {};
    win.document.createEvent = function() {
      return {
        initCustomEvent() {
          initCustomEventSpy();
        },
      };
    };
    createCustomEvent(win, 'foo', {bar: 123});
    expect(initCustomEventSpy).to.be.calledOnce;
  });

});


text:
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import { Injectable } from '@angular/core';

import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
import { CoreNavigator } from '@services/navigator';
import { makeSingleton } from '@singletons';

/**
 * Handler to treat links to user profiles.
 */
@Injectable({ providedIn: 'root' })
export class CoreUserProfileLinkHandlerService extends CoreContentLinksHandlerBase {

    name = 'CoreUserProfileLinkHandler';
    // Match user/view.php and user/profile.php but NOT grade/report/user/.
    pattern = /((\/user\/view\.php)|(\/user\/profile\.php)).*([?&]id=\d+)/;

    /**
     * Get the list of actions for a link (url).
     *
     * @param siteIds List of sites the URL belongs to.
     * @param url The URL to treat.
     * @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
     * @param courseId Course ID related to the URL. Optional but recommended.
     * @param data Extra data to handle the URL.
     * @return List of (or promise resolved with list of) actions.
     */
    getActions(
        siteIds: string[],
        url: string,
        params: Record<string, string>,
        courseId?: number, // eslint-disable-line @typescript-eslint/no-unused-vars
        data?: unknown, // eslint-disable-line @typescript-eslint/no-unused-vars
    ): CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
        return [{
            action: (siteId): void => {
                const pageParams = {
                    courseId: params.course,
                    userId: parseInt(params.id, 10),
                };

                CoreNavigator.navigateToSitePath('/user', { params: pageParams, siteId });
            },
        }];
    }

    /**
     * Check if the handler is enabled for a certain site (site + user) and a URL.
     * If not defined, defaults to true.
     *
     * @param siteId The site ID.
     * @param url The URL to treat.
     * @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
     * @param courseId Course ID related to the URL. Optional but recommended.
     * @return Whether the handler is enabled for the URL and site.
     */
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    async isEnabled(siteId: string, url: string, params: Record<string, string>, courseId?: number): Promise<boolean> {
        return url.indexOf('/grade/report/') == -1;
    }

}

export const CoreUserProfileLinkHandler = makeSingleton(CoreUserProfileLinkHandlerService);


text:
'use strict';

Object.defineProperty(exports, '__esModule', {
  value: true
});
exports['default'] = dmDialog;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _co = require('co');

var _co2 = _interopRequireDefault(_co);

var _coRequest = require('co-request');

var _coRequest2 = _interopRequireDefault(_coRequest);

var _modelsUser = require('../models/user');

var _modelsUser2 = _interopRequireDefault(_modelsUser);

var DOCOMO_API = "https://api.apigw.smt.docomo.ne.jp/dialogue/v1/dialogue?APIKEY=";
var DOCOMO_TOKEN = process.env.BOT_DOCOMO_TOKEN;

function dmDialog(adapter) {
  var api = adapter.api;
  var stream = api.stream('user');

  stream.on('direct_message', function (rcv) {
    var message = rcv.direct_message;
    var sender_id = message.sender_id_str;

    (0, _co2['default'])(function* () {
      if (sender_id === adapter.id) return;

      var foundUser = yield _modelsUser2['default'].find(sender_id);
      var user = foundUser ? foundUser : new _modelsUser2['default'](sender_id);
      var result = yield postDocomoDialog(user, message);

      user.context = result.context;
      yield user.save();

      var reply = { user_id: sender_id, text: result.utt };
      yield api.post('direct_messages/new', reply);
    })['catch'](function (err) {
      console.log(err);
    });
  });
}

function* postDocomoDialog(user, message) {
  var status = {};
  status.utt = message.text;
  status.nickname = message.sender_screen_name;
  if (user.context) status.context = user.context;

  var request = _coRequest2['default'].defaults({ strictSSL: false });
  var param = { body: JSON.stringify(status) };
  var result = yield request.post('' + DOCOMO_API + DOCOMO_TOKEN, param);

  return JSON.parse(result.body);
}
module.exports = exports['default'];


text:
using System;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.DatabaseAnnotations;

namespace Umbraco.Core.Models.Rdbms
{
    [TableName("umbracoServer")]
    [PrimaryKey("id")]
    [ExplicitColumns]
    internal class ServerRegistrationDto
    {
        [Column("id")]
        [PrimaryKeyColumn(AutoIncrement = true)]
        public int Id { get; set; }

        [Column("address")]
        [Length(500)]
        public string ServerAddress { get; set; }

        [Column("computerName")]
        [Length(255)]
        [Index(IndexTypes.UniqueNonClustered, Name = "IX_computerName")] // server identity is unique
        public string ServerIdentity { get; set; }

        [Column("registeredDate")]
        [Constraint(Default = "getdate()")]
        public DateTime DateRegistered { get; set; }

        [Column("lastNotifiedDate")]
        public DateTime DateAccessed { get; set; }

        [Column("isActive")]
        [Index(IndexTypes.NonClustered)]
        public bool IsActive { get; set; }

        [Column("isMaster")]
        public bool IsMaster { get; set; }
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?><!--This file was auto-generated by the jsystem runner, do not change it manually--><project default="execute scenario" name="scenarios/Dan Play and HTML">
    <property name="test.parameters.file.name" value=".testPropertiesFile_Empty"/>
    <property name="scenario.version" value="JSystem5_1"/>
    <property name="jsystem.uuid" value=""/>
    <property name="jsystem.parent.uuid" value=""/>
    <property name="jsystem.parent.name" value=""/>
    <loadproperties srcFile="${test.parameters.file.name}"/>
    <taskdef classname="com.aqua.anttask.jsystem.JSystemTask" name="jsystem"/>
    <taskdef classname="com.aqua.anttask.jsystem.JSystemAntTask" name="jsystem-ant"/>
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
    <typedef classname="com.aqua.anttask.jsystem.JSystemScriptCondition" name="jsystemscriptcondition"/>
    <taskdef classname="com.aqua.anttask.jsystem.JSystemSwitch" name="jsystemswitch"/>
    <taskdef classname="com.aqua.anttask.jsystem.JSystemForTask" name="jsystemfor"/>
    <taskdef classname="com.aqua.anttask.jsystem.JSystemSetAntProperties" name="jsystemsetantproperties"/>
    <target name="execute scenario">
        <antcallback target="t0"/>
        <antcallback target="t1"/>
        <antcallback target="t2"/>
        <antcallback target="t3"/>
    </target>
    <target name="t0">
        <jsystem showoutput="true">
            <sysproperty key="jsystem.uuid" value="664d6708-41e0-40ae-ac31-91b26eab977e"/>
            <sysproperty key="jsystem.parent.uuid" value="${jsystem.parent.uuid}.${jsystem.uuid}"/>
            <sysproperty key="jsystem.parent.name" value="${jsystem.parent.name}.${ant.project.name}"/>
            <test name="com.aqua.sanity.PlayButtonFunctionality.testCheckPlayButtonDisableWithAddDeleteTests"/>
        </jsystem>
    </target>
    <target name="t1">
        <jsystem showoutput="true">
            <sysproperty key="jsystem.uuid" value="9bce1572-6396-458a-88cd-d1a34efad434"/>
            <sysproperty key="jsystem.parent.uuid" value="${jsystem.parent.uuid}.${jsystem.uuid}"/>
            <sysproperty key="jsystem.parent.name" value="${jsystem.parent.name}.${ant.project.name}"/>
            <test name="com.aqua.sanity.PlayButtonFunctionality.testCheckPlayButtonDisableWithAddUncheckAll"/>
        </jsystem>
    </target>
    <target name="t2">
        <jsystem showoutput="true">
            <sysproperty key="jsystem.uuid" value="ff27fa0d-3876-48ea-87f1-6c6a31c782a4"/>
            <sysproperty key="jsystem.parent.uuid" value="${jsystem.parent.uuid}.${jsystem.uuid}"/>
            <sysproperty key="jsystem.parent.name" value="${jsystem.parent.name}.${ant.project.name}"/>
            <test name="com.aqua.sanity.PlayButtonFunctionality.testCheckPlayStatusWhenRunnerGoesUp"/>
        </jsystem>
    </target>
    <target name="t3">
        <jsystem showoutput="true">
            <sysproperty key="jsystem.uuid" value="2ca35f68-a5c3-4708-91fe-6613f83a6598"/>
            <sysproperty key="jsystem.parent.uuid" value="${jsystem.parent.uuid}.${jsystem.uuid}"/>
            <sysproperty key="jsystem.parent.name" value="${jsystem.parent.name}.${ant.project.name}"/>
            <test name="com.aqua.sanity.TestInformationPanelTestBasic.testCheckThatTestJavaDocIsInHTMLFormat"/>
        </jsystem>
    </target>
</project>


text:
exports.name = "FPWD";
exports.config = {
    status:             "WD"
,   longStatus:         "First Public Working Draft"
,   previousVersion:    false
,   styleSheet:         "W3C-WD"
,   stabilityWarning:   true
,   sotdStatus:         true
,   recTrackStatus:     true
};
exports.rules = require("./TR").rules;


text: export * from './components/card/Card';


text:
#ifndef VISITORS_LLVM_ASM_GENERATOR_HH
# define VISITORS_LLVM_ASM_GENERATOR_HH

# include <ostream>

# include <ozulis/ast/ast.hh>
# include <ozulis/visitors/visitor.hh>

namespace ozulis
{
  namespace visitors
  {
    /// @defgroup Visitors
    /**
     * @brief Generates LLVM assembly
     * @ingroup Visitors
     */
    class LLVMAsmGenerator : public ConstVisitor<LLVMAsmGenerator>
    {
    public:
      LLVMAsmGenerator(std::ostream & out);
      virtual ~LLVMAsmGenerator();

      static void initBase();

      void visitUDivExp(const ast::DivExp & node);
      void visitSDivExp(const ast::DivExp & node);
      void visitFDivExp(const ast::DivExp & node);
      void visitUModExp(const ast::ModExp & node);
      void visitSModExp(const ast::ModExp & node);
      void visitFModExp(const ast::ModExp & node);

      void writeFunctionHeader(const ast::FunctionDecl & node);

      std::ostream & out;
    };
  }
}

#endif /* !VISITORS_LLVM_ASM_GENERATOR_HH */


text:
using System.Threading.Tasks;
using HtcSharp.Core;
using HtcSharp.Core.Logging.Abstractions;
using HtcSharp.Core.Module.Abstractions;
using HtcSharp.Core.Plugin.Abstractions;

namespace HtcSharp.HttpModule {
    // SourceTools-Start
    // Ignore-Copyright
    // SourceTools-End
    public class HtcHttpModule : IModule {
        public string Name => "HtcHttp";
        public string Version => "1.0.5";

        public Task Load(HtcServer htcServer, ILogger logger) {
            htcServer.EngineManager.RegisterEngine("htc-http", typeof(HttpEngine));
            return Task.CompletedTask;
        }

        public Task Enable() {
            return Task.CompletedTask;
        }

        public Task Disable() {
            return Task.CompletedTask;
        }

        public bool IsCompatible(int htcMajor, int htcMinor, int htcPatch) {
            return true;
        }
    }
}


text:
ACCEPTED

#### According to
International Plant Names Index

#### Published in
null

#### Original name
Panicum sendulskyi Zuloaga & Morrone

### Remarks
null


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
null

#### Original name
Canthium captum Bullock

### Remarks
null


text: Write something about you.


text:
#include "VirtualFixtureBlock.h"

#include "core/Nodes.h"
#include "sacn/sacnlistener.h"
#include "utils.h"

VirtualFixtureBlock::VirtualFixtureBlock(MainController* controller, QString uid)
    : OneOutputBlock (controller, uid)
    , m_listener(nullptr)
    , m_universe(this, "universe", 1, 1, 63999)
    , m_channel(this, "channel", 1, 1, 512)
    , m_numChannels(this, "numChannels", 1, 1, 50)
    , m_actualChannelCount(this, "actualChannelCount", 1, 1, 50, /*persistent*/ false)
{
    updateListener();
    connect(&m_universe, &IntegerAttribute::valueChanged, this, &VirtualFixtureBlock::updateListener);
    connect(&m_numChannels, &IntegerAttribute::valueChanged, this, &VirtualFixtureBlock::updateNodeCount);
}

NodeBase* VirtualFixtureBlock::getChannelNode(int index) {
    if (index < 0 || index >= m_channelNodes.size()) return nullptr;
    return m_channelNodes[index];
}

void VirtualFixtureBlock::onLevelsChanged() {
    int level = m_listener->mergedLevels()[m_channel - 1].level;
    setValue(limit(0.0, level / 255.0, 1.0));

    for (int i=1; i<m_numChannels; ++i) {
        int ch = m_channel + i;
        if (ch > 512 || (i-1) >= m_channelNodes.size()) return;
        level = m_listener->mergedLevels()[ch - 1].level;
        m_channelNodes[i-1]->setValue(limit(0.0, level / 255.0, 1.0));
    }
}

void VirtualFixtureBlock::updateListener() {
    if (!m_listener.isNull()) {
        disconnect(m_listener.data(), &sACNListener::levelsChanged, this, &VirtualFixtureBlock::onLevelsChanged);
        m_listener.clear();
    }
    m_listener = sACNManager::getInstance()->getListener(m_universe);
    connect(m_listener.data(), &sACNListener::levelsChanged, this, &VirtualFixtureBlock::onLevelsChanged);
    onLevelsChanged();
}

void VirtualFixtureBlock::updateNodeCount() {
    int diff = m_numChannels - 1 - m_channelNodes.size();
    if (diff < 0) {
        for (int i=0; i < -diff; ++i) {
            NodeBase* node = m_channelNodes.last();
            m_channelNodes.pop_back();
            removeNode(node);
        }
    } else {
        for (int i=0; i<diff; ++i) {
            NodeBase* node = createOutputNode(QString::number(m_channelNodes.size()));
            m_channelNodes.append(node);
        }
    }
    m_actualChannelCount = m_numChannels.getValue();
}


text:
'use strict';
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');

if (cluster.isWorker) {

  // keep the worker alive
  const http = require('http');
  http.Server().listen(0, '127.0.0.1');

} else if (process.argv[2] === 'cluster') {

  const worker = cluster.fork();

  // send PID info to testcase process
  process.send({
    pid: worker.process.pid
  });

  // terminate the cluster process
  worker.once('listening', common.mustCall(() => {
    setTimeout(() => {
      process.exit(0);
    }, 1000);
  }));

} else {

  // This is the testcase
  const fork = require('child_process').fork;

  // Spawn a cluster process
  const master = fork(process.argv[1], ['cluster']);

  // get pid info
  let pid = null;
  master.once('message', (data) => {
    pid = data.pid;
  });

  // When master is dead
  let alive = true;
  master.on('exit', common.mustCall((code) => {

    // make sure that the master died on purpose
    assert.strictEqual(code, 0);

    // check worker process status
    const pollWorker = () => {
      alive = common.isAlive(pid);
      if (alive) {
        setTimeout(pollWorker, 50);
      }
    };
    // Loop indefinitely until worker exit.
    pollWorker();
  }));

  process.once('exit', () => {
    assert.strictEqual(typeof pid, 'number', 'did not get worker pid info');
    assert.strictEqual(alive, false, 'worker was alive after master died');
  });

}


text:
package com.yy.cloud.core.assess.data.repositories;

import com.yy.cloud.core.assess.data.domain.PerAPAAScore;
import com.yy.cloud.core.assess.data.domain.PerApAACountAndScore;
import com.yy.cloud.core.assess.data.domain.PerAssessAnswerItem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import java.util.List;

/**
 * Function: TODO ADD FUNCTION.

 * Reason:	 TODO ADD REASON.

 * Date:     10/29/17 8:43 PM

 *
 * @author chenxj
 * @see
 * @since JDK 1.8
 */
@RepositoryRestResource(collectionResourceRel = "perAssessAnswerItem", path = "perAssessAnswerItem")
public interface PerAssessAnswerItemRepository extends JpaRepository<PerAssessAnswerItem, String> {
    void deleteByTemplateId(String _templateId);
    @Modifying
    @Query(value = "DELETE FROM PerAssessAnswerItem pi where pi.id in (:itemIdList)")
    void deleteByIdIn(@Param("itemIdList") List<String> _idList);

    void deleteByTypeAndTemplateIdIn(Byte _type, List<String> _templateIdList);
    @Query(value = "SELECT pi.perAssessAnswer.id FROM PerAssessAnswerItem pi where pi.id in (:itemIdList)")
    List<String> getAssessAnswerList(@Param("itemIdList") List<String> _itemIdList);

    @Query(value = "SELECT sum(pi.markedScore) as markedScore, sum(pi.auditScore) as auditScore FROM PerAssessAnswerItem pi " +
            " where pi.id <> :assessAnswerItemId and pi.assessAnswerId = :assessAnswerId")
    PerAPAAScore getAssessAnswerScore(@Param("assessAnswerId") String _assessAnswerId, @Param("assessAnswerItemId") String _assessAnswerItemId);

    @Query(value = "SELECT sum(pi.markedScore) as markedScore, sum(pi.auditScore) as auditScore FROM PerAssessAnswerItem pi " +
            " where pi.id not in (:assessAnswerItemId) and pi.assessAnswerId = :assessAnswerId")
    PerAPAAScore getAssessAnswerScoreWithoutSomeAnswerItemIds(@Param("assessAnswerId") String _assessAnswerId, @Param("assessAnswerItemId") List<String> _assessAnswerItemId);

    @Query(value = "SELECT count(pi.id) as itemCount, sum(pi.markedScore) as markedScore, sum(pi.auditScore) as auditScore FROM PerAssessAnswerItem pi " +
            " where pi.assessAnswerId = :assessAnswerId")
    PerApAACountAndScore getAssessAnswerScoreAmount(@Param("assessAnswerId") String _assessAnswerId);

}


text:
typedef enum {
	stringswitch_enumerator_default_member_name(lcm_cmdcom),
	stringswitch_enumerator_member_name(lcm_cmdcom, u),
	stringswitch_enumerator_member_name(lcm_cmdcom, d),
	stringswitch_enumerator_member_name(lcm_cmdcom, f),
	stringswitch_enumerator_member_name(lcm_cmdcom, b),
	stringswitch_enumerator_member_name(lcm_cmdcom, a),
	stringswitch_enumerator_member_name(lcm_cmdcom, j),
	stringswitch_enumerator_member_name(lcm_cmdcom, s),
	stringswitch_enumerator_member_name(lcm_cmdcom, k),
	stringswitch_enumerator_member_name(lcm_cmdcom, a2),
	stringswitch_enumerator_member_name(lcm_cmdcom, a3),
	stringswitch_enumerator_member_name(lcm_cmdcom, a4),
} stringswitch_enumerator_name(lcm_cmdcom);

static int stringswitch_enumerator_eval_func(lcm_cmdcom) (char* str, size_t l) {
	switch(l) {
		case 1:
			switch(str[0]) {
				case 'u':
					return stringswitch_enumerator_member_name(lcm_cmdcom, u);
				case 'd':
					return stringswitch_enumerator_member_name(lcm_cmdcom, d);
				case 'f':
					return stringswitch_enumerator_member_name(lcm_cmdcom, f);
				case 'b':
					return stringswitch_enumerator_member_name(lcm_cmdcom, b);
				case 'a':
					return stringswitch_enumerator_member_name(lcm_cmdcom, a);
				case 'j':
					return stringswitch_enumerator_member_name(lcm_cmdcom, j);
				case 's':
					return stringswitch_enumerator_member_name(lcm_cmdcom, s);
				case 'k':
					return stringswitch_enumerator_member_name(lcm_cmdcom, k);
				default: goto main_default;
			}
		case 2:
			if(str[0]!='a') goto main_default;
			switch(str[1]) {
				case '2':
					return stringswitch_enumerator_member_name(lcm_cmdcom, a2);
				case '3':
					return stringswitch_enumerator_member_name(lcm_cmdcom, a3);
				case '4':
					return stringswitch_enumerator_member_name(lcm_cmdcom, a4);
				default: goto main_default;
			}
		default:
			main_default:
			return stringswitch_enumerator_default_member_name(lcm_cmdcom);
	}
}


text:
std::unique_ptr<Gdiplus::Bitmap> ImageLoader::loadFromFile(const wchar_t* fileName) {
    FILE* f = _wfopen(fileName, L"rb");
    if (!f) {
        lastError_ = str(boost::wformat(L"Cannot open file %s for reading.") % std::wstring(fileName));
        return nullptr;
    }
    uint8_t buffer[16];
    fread(buffer, 1, sizeof(buffer), f);
    fclose(f);
    ImageFormat format = getImageFormatFromData(buffer, sizeof(buffer));
    auto reader = createReaderForFormat(format);
    auto result = reader->readFromFile(fileName);
    if (!result) {
        lastError_ = reader->getLastError();
    }
    return result;
}

std::unique_ptr<Gdiplus::Bitmap> ImageLoader::loadFromMemory(uint8_t* data, size_t size) {
    ImageFormat format = getImageFormatFromData(data, sizeof(size));
    auto reader = createReaderForFormat(format);
    auto result = reader->readFromMemory(data, size);
    if (!result) {
        lastError_ = reader->getLastError();
    }
    return result;
}

std::unique_ptr<Gdiplus::Bitmap> ImageLoader::loadFromResource(HINSTANCE hInstance, LPCTSTR szResName,
    LPCTSTR szResType) {
    using namespace Gdiplus;
    HRSRC hrsrc = FindResource(hInstance, szResName, szResType);
    if (!hrsrc)
        return nullptr;
    // "Fake" HGLOBAL - look at MSDN
    HGLOBAL hg1 = LoadResource(hInstance, hrsrc);
    DWORD sz = SizeofResource(hInstance, hrsrc);
    void* ptr1 = LockResource(hg1);
    HGLOBAL hg2 = GlobalAlloc(GMEM_FIXED, sz);

    ImageFormat format = getImageFormatFromData(reinterpret_cast<uint8_t*>(ptr1), sz);

    // Copy raster data
    CopyMemory(LPVOID(hg2), ptr1, sz);
    IStream* pStream;

    // TRUE means free memory at Release
    HRESULT hr = CreateStreamOnHGlobal(hg2, TRUE, &pStream);
    if (FAILED(hr)) {
        return nullptr;
    }

    // use load from IStream
    auto reader = createReaderForFormat(format);
    auto result = reader->readFromStream(pStream);
    if (!result) {
        lastError_ = reader->getLastError();
    }
    pStream->Release();
    // GlobalFree(hg2);
    return result;
}

std::wstring ImageLoader::getLastError() const {
    return lastError_;
}

ImageFormat ImageLoader::getImageFormatFromData(uint8_t* data, size_t size) {
    if (size < 12) {
        return ImageFormat::Unknown;
    }
    if (data[0] == 'R' && data[1] == 'I' &&data[2] == 'F' &&data[3] == 'F'
        && data[8] == 'W' && data[9] == 'E' && data[10] == 'B'&& data[11] == 'P'
        ) {
        return ImageFormat::WebP;
    }
    return ImageFormat::Unknown;
}

std::unique_ptr<AbstractImageReader> ImageLoader::createReaderForFormat(ImageFormat format) {
    if (format == ImageFormat::WebP) {
        return std::make_unique<WebpImageReader>();
    }
    return std::make_unique<GdiplusImageReader>();
}