Fabulous Adventures In Coding

Eric Lippert's Blog

SimpleScript

Posts
  • Fabulous Adventures In Coding

    SimpleScript Part Seven: Binder Skeleton

    • 17 Comments
    In Part Five I was discussing modules: there is a "global module" and any number of additional modules. Each module is associated with a named item, and the only module which is associated with more than one named item is the global module. This means...
  • Fabulous Adventures In Coding

    invoke.cpp

    • 0 Comments
    #include "headers.h" HRESULT InvokeDispatch(IDispatch * pdisp, DISPID dispid, REFIID riid, LCID lcid, WORD flags, DISPPARAMS * pDispParams, VARIANT * pvarResult, EXCEPINFO * pExcepInfo, UINT * pError) { AssertReadPtr(pdisp); HRESULT hr; // We...
  • Fabulous Adventures In Coding

    invoke.h

    • 0 Comments
    #ifndef INVOKE_H // { #define INVOKE_H extern HRESULT InvokeDispatch(IDispatch * pdisp, DISPID dispid, REFIID riid, LCID lcid, WORD flags, DISPPARAMS * pDispParams, VARIANT * pvarResult, EXCEPINFO * pExcepInfo, UINT * pError); extern BOOL IsValidDispatch...
  • Fabulous Adventures In Coding

    binder.cpp

    • 1 Comments
    #include "headers.h" Binder::Binder() { DLLAddRef(); this->m_cref = 1; this->m_thread = GetCurrentThreadId(); } Binder::~Binder(void) { DLLRelease(); } HRESULT Binder::Create(Binder * * ppBinder) { AssertOutPtr(ppBinder); *ppBinder ...
  • Fabulous Adventures In Coding

    binder.h

    • 0 Comments
    #ifndef BINDER_H // { #define BINDER_H class Binder : public IDispatch { protected: class Name { public: Name(); ~Name(); HRESULT SetValue(VARIANTARG * pvar); HRESULT GetValue(VARIANT * pvar); BOOL IsFunction(void); HRESULT ExecuteFunction...
  • Fabulous Adventures In Coding

    SimpleScript Part Six: Threading Technicalities

    • 20 Comments
    Refresher Course Before you read this, you might want to take a quick refresher on my original posting on the script engine threading model. That was a somewhat simplified (!) description of the actual script engine contract. Let me just sum...
  • Fabulous Adventures In Coding

    SimpleScript Part Five: Named Items and Modules

    • 16 Comments
    Named Items "Named items" are what we call the "top level" objects of the host provided object model. WScript in WSH, window in Internet Explorer, Response in ASP, are all named items. A host tells an initialized script engine about named items...
  • Fabulous Adventures In Coding

    nameditemlist.h

    • 0 Comments
    #ifndef NAMEDITEMLIST_H // { #define NAMEDITEMLIST_H class NamedItemList { private: class NamedItem { private: NamedItem(); public: ~NamedItem(); static HRESULT Create(const WCHAR * pszName, NamedItem * * ppNamedItem); NamedItem * m_pNext;...
  • Fabulous Adventures In Coding

    nameditemlist.cpp

    • 2 Comments
    #include "headers.h" NamedItemList::NamedItemList() { this->m_cBuckets = 0; this->m_Buckets = NULL; this->m_pMutex = NULL; } NamedItemList::~NamedItemList() { this->Clear(); if (NULL != this->m_Buckets) delete[] this->m_Buckets;...
  • Fabulous Adventures In Coding

    mutex.cpp

    • 0 Comments
    #include "headers.h" Mutex::Mutex() { m_fInitialized = FALSE; } HRESULT Mutex::Create(Mutex * * ppMutex) { AssertOutPtr(ppMutex); HRESULT hr; BOOL fSuccess; DWORD error; Mutex * pMutex = NULL; pMutex = new Mutex(); if (NULL == pMutex) { hr...
  • Fabulous Adventures In Coding

    mutex.h

    • 0 Comments
    #ifndef MUTEX_H // { #define MUTEX_H class Mutex { private: CRITICAL_SECTION m_criticalsection; BOOL m_fInitialized; Mutex(); public: static HRESULT Create(Mutex * * ppMutex); ~Mutex(); void Enter(void); void Leave(void); }; #endif ...
  • Fabulous Adventures In Coding

    hash.h

    • 0 Comments
    #ifndef HASH_H // { #define HASH_H extern ULONG ComputeHash(const WCHAR * psz); #endif // HASH_H }
  • Fabulous Adventures In Coding

    hash.cpp

    • 0 Comments
    #include "headers.h" ULONG ComputeHash(const WCHAR * psz) { AssertReadString(psz); ULONG hash = 0; while (*psz != '\0') { hash = 17 * hash + *psz; ++psz; } return hash; }
  • Fabulous Adventures In Coding

    SimpleScript Part Four: Finite State Machines and Script Engines

    • 11 Comments
    Last time I said that I'd discuss finite state machines (also sometimes called finite state automata, same thing.) The FSM is a fundamental idea in theoretical computer science because it models computing machinery in a very simple, abstract and general...
  • Fabulous Adventures In Coding

    SimpleScript Part Three: Engine Skeleton

    • 3 Comments
    Before I get into today's topic I want to quickly address a minor defect that Raymond Chen (who apparently spends his holiday in Sweden doing remote code-reviews, oddly enough) was good enough to point out to me. It is legal to unload a DLL if the only...
  • Fabulous Adventures In Coding

    engine.h

    • 0 Comments
    #ifndef ENGINE_H // { #define ENGINE_H const DWORD threadNone = 0xFFFFFFFF; // The error has been reported to the host via IActiveScriptSite::OnScriptError const HRESULT SCRIPT_E_REPORTED = 0x80020101L; class ScriptEngine : public IActiveScript...
  • Fabulous Adventures In Coding

    engine.cpp

    • 1 Comments
    #include "headers.h" ScriptEngine::ScriptEngine() { DLLAddRef(); this->m_cref = 1; this->m_thread = threadNone; this->m_state = SCRIPTSTATE_UNINITIALIZED; this->m_psite = NULL; this->m_pNamedItemList = NULL; } ScriptEngine::~ScriptEngine...
  • Fabulous Adventures In Coding

    SimpleScript Part Two: Class Factories Are Also Boring

    • 7 Comments
    Before I get into it, a Lambda poster pointed me at the NullScript project, which is a very interesting illustration of how reverse engineering works. It's an implementation of a "null" script engine -- an engine with no language -- in ATL, which the...
  • Fabulous Adventures In Coding

    classfac.h

    • 0 Comments
    #ifndef CLASSFAC_H #define CLASSFAC_H class ClassFactory : public IClassFactory { private: long m_cref; ClassFactory(); ~ClassFactory(); public: static HRESULT Create(ClassFactory * * ppFactory); // IUnknown STDMETHODIMP QueryInterface...
  • Fabulous Adventures In Coding

    dllmain.h

    • 1 Comments
    #ifndef DLLMAIN_H // { #define DLLMAIN_H extern void DLLAddRef(void); extern void DLLRelease(void); extern void DLLAddLock(void); extern void DLLReleaseLock(void); #endif // DLLMAIN_H }
  • Fabulous Adventures In Coding

    classfac.cpp

    • 0 Comments
    #include "headers.h" // ClassFactory ClassFactory::ClassFactory() { m_cref = 1; } ClassFactory::~ClassFactory() { } HRESULT ClassFactory::Create(ClassFactory * * ppFactory) { AssertOutPtr(ppFactory); *ppFactory = new ClassFactory(); if (NULL...
  • Fabulous Adventures In Coding

    SimpleScript Part One: DllMain is Boring

    • 21 Comments
    In talking with our support engineer it's just become more muddled. I'm pretty sure now actually that the customer does not want to build a script engine, but whether they want to build a script editor, a script host or a script debugger is unclear. ...
  • Fabulous Adventures In Coding

    dllmain.cpp

    • 3 Comments
    #include "headers.h" // // Helper methods // static long g_cReferences = 0; static long g_cLocks = 0; static HMODULE g_hmodule = NULL; static const WCHAR * pszEngineName = L"SimpleScript"; static const WCHAR * pszOLEScript = L"OLEScript"; static...
  • Fabulous Adventures In Coding

    assert.cpp

    • 5 Comments
    #include "headers.h" static BOOL IsGoodPtr(void * pv, ULONG cb, DWORD dwFlags) { DWORD dwSize; MEMORY_BASIC_INFORMATION meminfo; if (NULL == pv) return FALSE; memset(&meminfo, 0x00, sizeof meminfo); dwSize = VirtualQuery(pv, &meminfo...
  • Fabulous Adventures In Coding

    assert.h

    • 0 Comments
    #ifndef ASSERT_H // { #define ASSERT_H extern BOOL Debugger(); extern BOOL AssertProc(const char *pszFile, long lwLine, const char *pszMsg); extern BOOL IsValidReadString(const WCHAR * psz); extern BOOL IsValidReadStringN(const WCHAR * psz); extern BOOL...
Page 1 of 2 (30 items) 12