text:
#ifndef B2_CONTACT_H
#define B2_CONTACT_H

#include <Box2D/Common/b2Math.h>
#include <Box2D/Collision/b2Collision.h>
#include <Box2D/Collision/Shapes/b2Shape.h>
#include <Box2D/Dynamics/b2Fixture.h>

class b2Body;
class b2Contact;
class b2Fixture;
class b2World;
class b2BlockAllocator;
class b2StackAllocator;
class b2ContactListener;

/// Friction mixing law. The idea is to allow either fixture to drive the restitution to zero.
/// For example, anything slides on ice.
inline float32 b2MixFriction(float32 friction1, float32 friction2)
{
    return std::sqrt(friction1 * friction2);
}

/// Restitution mixing law. The idea is allow for anything to bounce off an inelastic surface.
/// For example, a superball bounces on anything.
inline float32 b2MixRestitution(float32 restitution1, float32 restitution2)
{
    return restitution1 > restitution2 ? restitution1 : restitution2;
}

typedef b2Contact* b2ContactCreateFcn(    b2Fixture* fixtureA, int32 indexA,
                                        b2Fixture* fixtureB, int32 indexB,
                                        b2BlockAllocator* allocator);
typedef void b2ContactDestroyFcn(b2Contact* contact, b2BlockAllocator* allocator);

struct b2ContactRegister
{
    b2ContactCreateFcn* createFcn;
    b2ContactDestroyFcn* destroyFcn;
    bool primary;
};

/// A contact edge is used to connect bodies and contacts together
/// in a contact graph where each body is a node and each contact
/// is an edge. A contact edge belongs to a doubly linked list
/// maintained in each attached body. Each contact has two contact
/// nodes, one for each attached body.
struct b2ContactEdge
{
    b2Body* other;            ///< provides quick access to the other body attached.
    b2Contact* contact;        ///< the contact
    b2ContactEdge* prev;    ///< the previous contact edge in the body's contact list
    b2ContactEdge* next;    ///< the next contact edge in the body's contact list
};

/// The class manages contact between two shapes. A contact exists for each overlapping
/// AABB in the broad-phase (except if filtered). Therefore a contact object may exist
/// that has no contact points.
class b2Contact
{
public:

    /// Get the contact manifold. Do not modify the manifold unless you understand the
    /// internals of Box2D.
    b2Manifold* GetManifold();
    const b2Manifold* GetManifold() const;

    /// Get the world manifold.
    void GetWorldManifold(b2WorldManifold* worldManifold) const;

    /// Is this contact touching?
    bool IsTouching() const;

    /// Enable/disable this contact. This can be used inside the pre-solve
    /// contact listener. The contact is only disabled for the current
    /// time step (or sub-step in continuous collisions).
    void SetEnabled(bool flag);

    /// Has this contact been disabled?
    bool IsEnabled() const;

    /// Get the next contact in the world's contact list.
    b2Contact* GetNext();
    const b2Contact* GetNext() const;

    /// Get fixture A in this contact.
    b2Fixture* GetFixtureA();
    const b2Fixture* GetFixtureA() const;

    /// Get the child primitive index for fixture A.
    int32 GetChildIndexA() const;

    /// Get fixture B in this contact.
    b2Fixture* GetFixtureB();
    const b2Fixture* GetFixtureB() const;

    /// Get the child primitive index for fixture B.
    int32 GetChildIndexB() const;

    /// Override the default friction mixture. You can call this in b2ContactListener::PreSolve.
    /// This value persists until set or reset.
    void SetFriction(float32 friction);

    /// Get the friction.
    float32 GetFriction() const;

    /// Reset the friction mixture to the default value.
    void ResetFriction();

    /// Override the default restitution mixture. You can call this in b2ContactListener::PreSolve.
    /// The value persists until you set or reset.
    void SetRestitution(float32 restitution);

    /// Get the restitution.
    float32 GetRestitution() const;

    /// Reset the restitution to the default value.
    void ResetRestitution();

    /// Evaluate this contact with your own manifold and transforms.
    virtual void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB) = 0;

protected:
    friend class b2ContactManager;
    friend class b2World;
    friend class b2ContactSolver;
    friend class b2Body;
    friend class b2Fixture;

    // Flags stored in m_flags
    enum
    {
        // Used when crawling contact graph when forming islands.
        e_islandFlag        = 0x0001,

        // Set when the shapes are touching.
        e_touchingFlag        = 0x0002,

        // This contact can be disabled (by user)
        e_enabledFlag        = 0x0004,

        // This contact needs filtering because a fixture filter was changed.
        e_filterFlag        = 0x0008,

        // This bullet contact had a TOI event
        e_bulletHitFlag        = 0x0010,

        // This contact has a valid TOI in m_toi
        e_toiFlag            = 0x0020
    };

    /// Flag this contact for filtering. Filtering will occur the next time step.
    void FlagForFiltering();

    static void AddType(b2ContactCreateFcn* createFcn, b2ContactDestroyFcn* destroyFcn,
                        b2Shape::Type typeA, b2Shape::Type typeB);
    static void InitializeRegisters();
    static b2Contact* Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator);
    static void Destroy(b2Contact* contact, b2Shape::Type typeA, b2Shape::Type typeB, b2BlockAllocator* allocator);
    static void Destroy(b2Contact* contact, b2BlockAllocator* allocator);

    b2Contact() : m_fixtureA(NULL), m_fixtureB(NULL) {}
    b2Contact(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB);
    virtual ~b2Contact() {}

    void Update(b2ContactListener* listener);

    static b2ContactRegister s_registers[b2Shape::e_typeCount][b2Shape::e_typeCount];
    static bool s_initialized;

    uint32 m_flags;

    // World pool and list pointers.
    b2Contact* m_prev;
    b2Contact* m_next;

    // Nodes for connecting bodies.
    b2ContactEdge m_nodeA;
    b2ContactEdge m_nodeB;

    b2Fixture* m_fixtureA;
    b2Fixture* m_fixtureB;

    int32 m_indexA;
    int32 m_indexB;

    b2Manifold m_manifold;

    int32 m_toiCount;
    float32 m_toi;

    float32 m_friction;
    float32 m_restitution;
};

inline b2Manifold* b2Contact::GetManifold()
{
    return &m_manifold;
}

inline const b2Manifold* b2Contact::GetManifold() const
{
    return &m_manifold;
}

inline void b2Contact::GetWorldManifold(b2WorldManifold* worldManifold) const
{
    const b2Body* bodyA = m_fixtureA->GetBody();
    const b2Body* bodyB = m_fixtureB->GetBody();
    const b2Shape* shapeA = m_fixtureA->GetShape();
    const b2Shape* shapeB = m_fixtureB->GetShape();

    worldManifold->Initialize(&m_manifold, bodyA->GetTransform(), shapeA->m_radius, bodyB->GetTransform(), shapeB->m_radius);
}

inline void b2Contact::SetEnabled(bool flag)
{
    if (flag)
    {
        m_flags |= e_enabledFlag;
    }
    else
    {
        m_flags &= ~e_enabledFlag;
    }
}

inline bool b2Contact::IsEnabled() const
{
    return (m_flags & e_enabledFlag) == e_enabledFlag;
}

inline bool b2Contact::IsTouching() const
{
    return (m_flags & e_touchingFlag) == e_touchingFlag;
}

inline b2Contact* b2Contact::GetNext()
{
    return m_next;
}

inline const b2Contact* b2Contact::GetNext() const
{
    return m_next;
}

inline b2Fixture* b2Contact::GetFixtureA()
{
    return m_fixtureA;
}

inline const b2Fixture* b2Contact::GetFixtureA() const
{
    return m_fixtureA;
}

inline b2Fixture* b2Contact::GetFixtureB()
{
    return m_fixtureB;
}

inline int32 b2Contact::GetChildIndexA() const
{
    return m_indexA;
}

inline const b2Fixture* b2Contact::GetFixtureB() const
{
    return m_fixtureB;
}

inline int32 b2Contact::GetChildIndexB() const
{
    return m_indexB;
}

inline void b2Contact::FlagForFiltering()
{
    m_flags |= e_filterFlag;
}

inline void b2Contact::SetFriction(float32 friction)
{
    m_friction = friction;
}

inline float32 b2Contact::GetFriction() const
{
    return m_friction;
}

inline void b2Contact::ResetFriction()
{
    m_friction = b2MixFriction(m_fixtureA->m_friction, m_fixtureB->m_friction);
}

inline void b2Contact::SetRestitution(float32 restitution)
{
    m_restitution = restitution;
}

inline float32 b2Contact::GetRestitution() const
{
    return m_restitution;
}

inline void b2Contact::ResetRestitution()
{
    m_restitution = b2MixRestitution(m_fixtureA->m_restitution, m_fixtureB->m_restitution);
}

#endif


text:
package org.apache.drill.exec.vector.complex.impl;

import java.util.Iterator;

import org.apache.drill.common.types.TypeProtos.MajorType;
import org.apache.drill.common.types.TypeProtos.MinorType;
import org.apache.drill.common.types.Types;
import org.apache.drill.exec.vector.complex.RepeatedMapVector;
import org.apache.drill.exec.vector.complex.reader.FieldReader;
import org.apache.drill.exec.vector.complex.writer.BaseWriter.MapWriter;

public class SingleLikeRepeatedMapReaderImpl extends AbstractFieldReader{

  private RepeatedMapReaderImpl delegate;

  public SingleLikeRepeatedMapReaderImpl(RepeatedMapVector vector, FieldReader delegate) {
    this.delegate = (RepeatedMapReaderImpl) delegate;
  }

  @Override
  public int size() {
    throw new UnsupportedOperationException("You can't call size on a single map reader.");
  }

  @Override
  public boolean next() {
    throw new UnsupportedOperationException("You can't call next on a single map reader.");
  }

  @Override
  public MajorType getType() {
    return Types.required(MinorType.MAP);
  }

  @Override
  public void copyAsValue(MapWriter writer) {
    delegate.copyAsValueSingle(writer);
  }

  public void copyAsValueSingle(MapWriter writer){
    delegate.copyAsValueSingle(writer);
  }

  @Override
  public FieldReader reader(String name) {
    return delegate.reader(name);
  }

  @Override
  public void setPosition(int index) {
    delegate.setPosition(index);
  }

  @Override
  public Object readObject() {
    return delegate.readObject();
  }

  @Override
  public Iterator<String> iterator() {
    return delegate.iterator();
  }

  @Override
  public boolean isSet() {
    return ! delegate.isNull();
  }

}

redpajama_set_name: RedPajamaGithub


text:
package org.bytesoft.openjtcc.supports.adapter.work;

import javax.resource.spi.work.Work;
import javax.resource.spi.work.WorkEvent;
import javax.resource.spi.work.WorkListener;

import org.bytesoft.openjtcc.task.TransactionTimingTask;

public class TransactionTimingWork extends TransactionTimingTask implements Work, WorkListener {
	private boolean completed = false;

	public void workAccepted(WorkEvent workEvent) {
	}

	public void workCompleted(WorkEvent workEvent) {
		this.completed = true;
	}

	public void workRejected(WorkEvent workEvent) {
	}

	public void workStarted(WorkEvent workEvent) {
	}

	public boolean isCompleted() {
		return completed;
	}

	public void setCompleted(boolean completed) {
		this.completed = completed;
	}

}


text:
package io.cattle.platform.engine.task;

import io.cattle.platform.engine.server.ProcessServer;
import io.cattle.platform.task.Task;

public class ProcessReplayTask implements Task {

    ProcessServer processServer;

    public ProcessReplayTask(ProcessServer processServer) {
        this.processServer = processServer;
    }

    @Override
    public void run() {
        processServer.runOutstandingJobs();
    }

    @Override
    public String getName() {
        return "process.replay";
    }

}


text:
 #define _GLFW_X11_CONTEXT_VISUAL window->glx.visual
 #include "glx_platform.h"
#elif defined(_GLFW_EGL)
 #define _GLFW_X11_CONTEXT_VISUAL window->egl.visual
 #define _GLFW_EGL_NATIVE_WINDOW  window->x11.handle
 #define _GLFW_EGL_NATIVE_DISPLAY _glfw.x11.display
 #include "egl_platform.h"
#else
 #error "No supported context creation API selected"
#endif

#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowX11  x11
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11
#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorX11 x11

//========================================================================
// GLFW platform specific types
//========================================================================

//------------------------------------------------------------------------
// Platform-specific window structure
//------------------------------------------------------------------------
typedef struct _GLFWwindowX11
{
    // Platform specific window resources
    Colormap        colormap;          // Window colormap
    Window          handle;            // Window handle

    // Various platform specific internal variables
    GLboolean       overrideRedirect; // True if window is OverrideRedirect
    GLboolean       cursorGrabbed;    // True if cursor is currently grabbed
    GLboolean       cursorHidden;     // True if cursor is currently hidden

    // Cached position and size used to filter out duplicate events
    int             width, height;
    int             xpos, ypos;

    // The last received cursor position, regardless of source
    double          cursorPosX, cursorPosY;
    // The last position the cursor was warped to by GLFW
    int             warpPosX, warpPosY;

} _GLFWwindowX11;

//------------------------------------------------------------------------
// Platform-specific library global data for X11
//------------------------------------------------------------------------
typedef struct _GLFWlibraryX11
{
    Display*        display;
    int             screen;
    Window          root;

    // Invisible cursor for hidden cursor mode
    Cursor          cursor;
    XContext        context;

    // Window manager atoms
    Atom            WM_STATE;
    Atom            WM_DELETE_WINDOW;
    Atom            NET_WM_NAME;
    Atom            NET_WM_ICON_NAME;
    Atom            NET_WM_PID;
    Atom            NET_WM_PING;
    Atom            NET_WM_STATE;
    Atom            NET_WM_STATE_FULLSCREEN;
    Atom            NET_ACTIVE_WINDOW;
    Atom            MOTIF_WM_HINTS;

    // Selection atoms
    Atom            TARGETS;
    Atom            MULTIPLE;
    Atom            CLIPBOARD;
    Atom            CLIPBOARD_MANAGER;
    Atom            SAVE_TARGETS;
    Atom            UTF8_STRING;
    Atom            COMPOUND_STRING;
    Atom            ATOM_PAIR;
    Atom            GLFW_SELECTION;

    // True if window manager supports EWMH
    GLboolean       hasEWMH;

    // Error code received by the X error handler
    int             errorCode;

    struct {
        GLboolean   available;
        int         eventBase;
        int         errorBase;
    } vidmode;

    struct {
        GLboolean   available;
        int         eventBase;
        int         errorBase;
        int         versionMajor;
        int         versionMinor;
        GLboolean   gammaBroken;
    } randr;

    struct {
        int         majorOpcode;
        int         eventBase;
        int         errorBase;
        int         versionMajor;
        int         versionMinor;
    } xkb;

    struct {
        GLboolean   available;
        int         majorOpcode;
        int         eventBase;
        int         errorBase;
        int         versionMajor;
        int         versionMinor;
    } xi;

    // LUT for mapping X11 key codes to GLFW key codes
    int             keyCodeLUT[256];

    struct {
        int         count;
        int         timeout;
        int         interval;
        int         blanking;
        int         exposure;
    } saver;

    struct {
        GLboolean   monotonic;
        double      resolution;
        uint64_t    base;
    } timer;

    struct {
        char*       string;
    } selection;

    struct {
        int         present;
        int         fd;
        float*      axes;
        int         axisCount;
        unsigned char* buttons;
        int         buttonCount;
        char*       name;
    } joystick[GLFW_JOYSTICK_LAST + 1];

} _GLFWlibraryX11;

//------------------------------------------------------------------------
// Platform-specific monitor structure
//------------------------------------------------------------------------
typedef struct _GLFWmonitorX11
{
//    RROutput        output;
//    RRCrtc          crtc;
//    RRMode          oldMode;

} _GLFWmonitorX11;

//========================================================================
// Prototypes for platform specific internal functions
//========================================================================

// Time
void _glfwInitTimer(void);

// Gamma
void _glfwInitGammaRamp(void);

// OpenGL support
int _glfwInitContextAPI(void);
void _glfwTerminateContextAPI(void);
int _glfwCreateContext(_GLFWwindow* window,
                       const _GLFWwndconfig* wndconfig,
                       const _GLFWfbconfig* fbconfig);
void _glfwDestroyContext(_GLFWwindow* window);

// Fullscreen support
void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired);
void _glfwRestoreVideoMode(_GLFWmonitor* monitor);

// Joystick input
void _glfwInitJoysticks(void);
void _glfwTerminateJoysticks(void);

// Unicode support
long _glfwKeySym2Unicode(KeySym keysym);

// Clipboard handling
void _glfwHandleSelectionClear(XEvent* event);
void _glfwHandleSelectionRequest(XEvent* event);
void _glfwPushSelectionToManager(_GLFWwindow* window);

// Window support
_GLFWwindow* _glfwFindWindowByHandle(Window handle);
unsigned long _glfwGetWindowProperty(Window window,
                                     Atom property,
                                     Atom type,
                                     unsigned char** value);

// X11 error handler
void _glfwGrabXErrorHandler(void);
void _glfwReleaseXErrorHandler(void);
void _glfwInputXError(int error, const char* message);

#endif // _x11_platform_h_


text:
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "mozilla/chrome/RegistryMessageUtils.h"

#include "nsResProtocolHandler.h"
#include "nsIURL.h"
#include "nsIIOService.h"
#include "nsIServiceManager.h"
#include "prenv.h"
#include "prmem.h"
#include "prprf.h"
#include "nsXPIDLString.h"
#include "nsIFile.h"
#include "nsDirectoryServiceDefs.h"
#include "nsNetUtil.h"
#include "nsURLHelper.h"
#include "nsEscape.h"

#include "mozilla/Omnijar.h"

static NS_DEFINE_CID(kResURLCID, NS_RESURL_CID);

static nsResProtocolHandler *gResHandler = nullptr;

#if defined(PR_LOGGING)
//
// Log module for Resource Protocol logging...
//
// To enable logging (see prlog.h for full details):
//
//    set NSPR_LOG_MODULES=nsResProtocol:5
//    set NSPR_LOG_FILE=log.txt
//
// this enables PR_LOG_ALWAYS level information and places all output in
// the file log.txt
//
static PRLogModuleInfo *gResLog;
#endif

#define kAPP           NS_LITERAL_CSTRING("app")
#define kGRE           NS_LITERAL_CSTRING("gre")

//----------------------------------------------------------------------------
// nsResURL : overrides nsStandardURL::GetFile to provide nsIFile resolution
//----------------------------------------------------------------------------

nsresult
nsResURL::EnsureFile()
{
    nsresult rv;

    NS_ENSURE_TRUE(gResHandler, NS_ERROR_NOT_AVAILABLE);

    nsAutoCString spec;
    rv = gResHandler->ResolveURI(this, spec);
    if (NS_FAILED(rv))
        return rv;

    nsAutoCString scheme;
    rv = net_ExtractURLScheme(spec, nullptr, nullptr, &scheme);
    if (NS_FAILED(rv))
        return rv;

    // Bug 585869:
    // In most cases, the scheme is jar if it's not file.
    // Regardless, net_GetFileFromURLSpec should be avoided
    // when the scheme isn't file.
    if (!scheme.Equals(NS_LITERAL_CSTRING("file")))
        return NS_ERROR_NO_INTERFACE;

    rv = net_GetFileFromURLSpec(spec, getter_AddRefs(mFile));
#ifdef DEBUG_bsmedberg
    if (NS_SUCCEEDED(rv)) {
        bool exists = true;
        mFile->Exists(&exists);
        if (!exists) {
            printf("resource %s doesn't exist!\n", spec.get());
        }
    }
#endif

    return rv;
}

/* virtual */ nsStandardURL*
nsResURL::StartClone()
{
    nsResURL *clone = new nsResURL();
    return clone;
}

NS_IMETHODIMP
nsResURL::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
{
    *aClassIDNoAlloc = kResURLCID;
    return NS_OK;
}

//----------------------------------------------------------------------------
// nsResProtocolHandler <public>
//----------------------------------------------------------------------------

nsResProtocolHandler::nsResProtocolHandler()
{
#if defined(PR_LOGGING)
    gResLog = PR_NewLogModule("nsResProtocol");
#endif

    NS_ASSERTION(!gResHandler, "res handler already created!");
    gResHandler = this;
}

nsResProtocolHandler::~nsResProtocolHandler()
{
    gResHandler = nullptr;
}

nsresult
nsResProtocolHandler::Init()
{
    mSubstitutions.Init(32);

    nsresult rv;

    mIOService = do_GetIOService(&rv);
    NS_ENSURE_SUCCESS(rv, rv);

    nsAutoCString appURI, greURI;
    rv = mozilla::Omnijar::GetURIString(mozilla::Omnijar::APP, appURI);
    NS_ENSURE_SUCCESS(rv, rv);
    rv = mozilla::Omnijar::GetURIString(mozilla::Omnijar::GRE, greURI);
    NS_ENSURE_SUCCESS(rv, rv);

    //
    // make resource:/// point to the application directory or omnijar
    //
    nsCOMPtr<nsIURI> uri;
    rv = NS_NewURI(getter_AddRefs(uri), appURI.Length() ? appURI : greURI);
    NS_ENSURE_SUCCESS(rv, rv);

    rv = SetSubstitution(EmptyCString(), uri);
    NS_ENSURE_SUCCESS(rv, rv);

    //
    // make resource://app/ point to the application directory or omnijar
    //
    rv = SetSubstitution(kAPP, uri);
    NS_ENSURE_SUCCESS(rv, rv);

    //
    // make resource://gre/ point to the GRE directory
    //
    if (appURI.Length()) { // We already have greURI in uri if appURI.Length() is 0.
        rv = NS_NewURI(getter_AddRefs(uri), greURI);
        NS_ENSURE_SUCCESS(rv, rv);
    }

    rv = SetSubstitution(kGRE, uri);
    NS_ENSURE_SUCCESS(rv, rv);

    //XXXbsmedberg Neil wants a resource://pchrome/ for the profile chrome dir...
    // but once I finish multiple chrome registration I'm not sure that it is needed

    // XXX dveditz: resource://pchrome/ defeats profile directory salting
    // if web content can load it. Tread carefully.

    return rv;
}

static PLDHashOperator
EnumerateSubstitution(const nsACString& aKey,
                      nsIURI* aURI,
                      void* aArg)
{
    nsTArray<ResourceMapping>* resources =
            static_cast<nsTArray<ResourceMapping>*>(aArg);
    SerializedURI uri;
    if (aURI) {
        aURI->GetSpec(uri.spec);
        aURI->GetOriginCharset(uri.charset);
    }

    ResourceMapping resource = {
        nsCString(aKey), uri
    };
    resources->AppendElement(resource);
    return (PLDHashOperator)PL_DHASH_NEXT;
}

void
nsResProtocolHandler::CollectSubstitutions(InfallibleTArray<ResourceMapping>& aResources)
{
    mSubstitutions.EnumerateRead(&EnumerateSubstitution, &aResources);
}

//----------------------------------------------------------------------------
// nsResProtocolHandler::nsISupports
//----------------------------------------------------------------------------

NS_IMPL_THREADSAFE_ISUPPORTS3(nsResProtocolHandler,
                              nsIResProtocolHandler,
                              nsIProtocolHandler,
                              nsISupportsWeakReference)

//----------------------------------------------------------------------------
// nsResProtocolHandler::nsIProtocolHandler
//----------------------------------------------------------------------------

NS_IMETHODIMP
nsResProtocolHandler::GetScheme(nsACString &result)
{
    result.AssignLiteral("resource");
    return NS_OK;
}

NS_IMETHODIMP
nsResProtocolHandler::GetDefaultPort(int32_t *result)
{
    *result = -1;        // no port for res: URLs
    return NS_OK;
}

NS_IMETHODIMP
nsResProtocolHandler::GetProtocolFlags(uint32_t *result)
{
    // XXXbz Is this really true for all resource: URIs?  Could we
    // somehow give different flags to some of them?
    *result = URI_STD | URI_IS_UI_RESOURCE | URI_IS_LOCAL_RESOURCE;
    return NS_OK;
}

NS_IMETHODIMP
nsResProtocolHandler::NewURI(const nsACString &aSpec,
                             const char *aCharset,
                             nsIURI *aBaseURI,
                             nsIURI **result)
{
    nsresult rv;

    nsResURL *resURL = new nsResURL();
    if (!resURL)
        return NS_ERROR_OUT_OF_MEMORY;
    NS_ADDREF(resURL);

    // unescape any %2f and %2e to make sure nsStandardURL coalesces them.
    // Later net_GetFileFromURLSpec() will do a full unescape and we want to
    // treat them the same way the file system will. (bugs 380994, 394075)
    nsAutoCString spec;
    const char *src = aSpec.BeginReading();
    const char *end = aSpec.EndReading();
    const char *last = src;

    spec.SetCapacity(aSpec.Length()+1);
    for ( ; src < end; ++src) {
        if (*src == '%' && (src < end-2) && *(src+1) == '2') {
           char ch = '\0';
           if (*(src+2) == 'f' || *(src+2) == 'F')
             ch = '/';
           else if (*(src+2) == 'e' || *(src+2) == 'E')
             ch = '.';

           if (ch) {
             if (last < src)
               spec.Append(last, src-last);
             spec.Append(ch);
             src += 2;
             last = src+1; // src will be incremented by the loop
           }
        }
    }
    if (last < src)
      spec.Append(last, src-last);

    rv = resURL->Init(nsIStandardURL::URLTYPE_STANDARD, -1, spec, aCharset, aBaseURI);
    if (NS_SUCCEEDED(rv))
        rv = CallQueryInterface(resURL, result);
    NS_RELEASE(resURL);
    return rv;
}

NS_IMETHODIMP
nsResProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
{
    NS_ENSURE_ARG_POINTER(uri);
    nsresult rv;
    nsAutoCString spec;

    rv = ResolveURI(uri, spec);
    if (NS_FAILED(rv)) return rv;

    rv = mIOService->NewChannel(spec, nullptr, nullptr, result);
    if (NS_FAILED(rv)) return rv;

    nsLoadFlags loadFlags = 0;
    (*result)->GetLoadFlags(&loadFlags);
    (*result)->SetLoadFlags(loadFlags & ~nsIChannel::LOAD_REPLACE);
    return (*result)->SetOriginalURI(uri);
}

NS_IMETHODIMP
nsResProtocolHandler::AllowPort(int32_t port, const char *scheme, bool *_retval)
{
    // don't override anything.
    *_retval = false;
    return NS_OK;
}

//----------------------------------------------------------------------------
// nsResProtocolHandler::nsIResProtocolHandler
//----------------------------------------------------------------------------

NS_IMETHODIMP
nsResProtocolHandler::SetSubstitution(const nsACString& root, nsIURI *baseURI)
{
    if (!baseURI) {
        mSubstitutions.Remove(root);
        return NS_OK;
    }

    // If baseURI isn't a resource URI, we can set the substitution immediately.
    nsAutoCString scheme;
    nsresult rv = baseURI->GetScheme(scheme);
    NS_ENSURE_SUCCESS(rv, rv);
    if (!scheme.Equals(NS_LITERAL_CSTRING("resource"))) {
        mSubstitutions.Put(root, baseURI);
        return NS_OK;
    }

    // baseURI is a resource URI, let's resolve it first.
    nsAutoCString newBase;
    rv = ResolveURI(baseURI, newBase);
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMPtr<nsIURI> newBaseURI;
    rv = mIOService->NewURI(newBase, nullptr, nullptr,
                            getter_AddRefs(newBaseURI));
    NS_ENSURE_SUCCESS(rv, rv);

    mSubstitutions.Put(root, newBaseURI);
    return NS_OK;
}

NS_IMETHODIMP
nsResProtocolHandler::GetSubstitution(const nsACString& root, nsIURI **result)
{
    NS_ENSURE_ARG_POINTER(result);

    if (mSubstitutions.Get(root, result))
        return NS_OK;

    // try invoking the directory service for "resource:root"

    nsAutoCString key;
    key.AssignLiteral("resource:");
    key.Append(root);

    nsCOMPtr<nsIFile> file;
    nsresult rv = NS_GetSpecialDirectory(key.get(), getter_AddRefs(file));
    if (NS_FAILED(rv))
        return NS_ERROR_NOT_AVAILABLE;

    rv = mIOService->NewFileURI(file, result);
    if (NS_FAILED(rv))
        return NS_ERROR_NOT_AVAILABLE;

    return NS_OK;
}

NS_IMETHODIMP
nsResProtocolHandler::HasSubstitution(const nsACString& root, bool *result)
{
    NS_ENSURE_ARG_POINTER(result);

    *result = mSubstitutions.Get(root, nullptr);
    return NS_OK;
}

NS_IMETHODIMP
nsResProtocolHandler::ResolveURI(nsIURI *uri, nsACString &result)
{
    nsresult rv;

    nsAutoCString host;
    nsAutoCString path;

    rv = uri->GetAsciiHost(host);
    if (NS_FAILED(rv)) return rv;

    rv = uri->GetPath(path);
    if (NS_FAILED(rv)) return rv;

    // Unescape the path so we can perform some checks on it.
    nsAutoCString unescapedPath(path);
    NS_UnescapeURL(unescapedPath);

    // Don't misinterpret the filepath as an absolute URI.
    if (unescapedPath.FindChar(':') != -1)
        return NS_ERROR_MALFORMED_URI;

    if (unescapedPath.FindChar('\\') != -1)
        return NS_ERROR_MALFORMED_URI;

    const char *p = path.get() + 1; // path always starts with a slash
    NS_ASSERTION(*(p-1) == '/', "Path did not begin with a slash!");

    if (*p == '/')
        return NS_ERROR_MALFORMED_URI;

    nsCOMPtr<nsIURI> baseURI;
    rv = GetSubstitution(host, getter_AddRefs(baseURI));
    if (NS_FAILED(rv)) return rv;

    rv = baseURI->Resolve(nsDependentCString(p, path.Length()-1), result);

#if defined(PR_LOGGING)
    if (PR_LOG_TEST(gResLog, PR_LOG_DEBUG)) {
        nsAutoCString spec;
        uri->GetAsciiSpec(spec);
        PR_LOG(gResLog, PR_LOG_DEBUG,
               ("%s\n -> %s\n", spec.get(), PromiseFlatCString(result).get()));
    }
#endif
    return rv;
}


text:
using System.Diagnostics;
using System.Text;

namespace System.IO
{
    public static partial class Path
    {
        public static readonly char DirectorySeparatorChar = '\\';
        public static readonly char VolumeSeparatorChar = ':';
        public static readonly char PathSeparator = ';';

        private const string DirectorySeparatorCharAsString = "\\";

        private static readonly char[] InvalidFileNameChars =
        {
            '\"', '<', '>', '|', '\0',
            (char)1, (char)2, (char)3, (char)4, (char)5, (char)6, (char)7, (char)8, (char)9, (char)10,
            (char)11, (char)12, (char)13, (char)14, (char)15, (char)16, (char)17, (char)18, (char)19, (char)20,
            (char)21, (char)22, (char)23, (char)24, (char)25, (char)26, (char)27, (char)28, (char)29, (char)30,
            (char)31, ':', '*', '?', '\\', '/'
        };

        // The max total path is 260, and the max individual component length is 255.
        // For example, D:\<256 char file name> isn't legal, even though it's under 260 chars.
        internal static readonly int MaxPath = 260;
        internal static readonly int MaxLongPath = short.MaxValue;

        // Expands the given path to a fully qualified path.
        public static string GetFullPath(string path)
        {
            if (path == null)
                throw new ArgumentNullException(nameof(path));

            // Embedded null characters are the only invalid character case we want to check up front.
            // This is because the nulls will signal the end of the string to Win32 and therefore have
            // unpredictable results. Other invalid characters we give a chance to be normalized out.
            if (path.IndexOf('\0') != -1)
                throw new ArgumentException(SR.Argument_InvalidPathChars, nameof(path));

            if (PathInternal.IsExtended(path))
            {
                // We can't really know what is valid for all cases of extended paths.
                //
                //  - object names can include other characters as well (':', '/', etc.)
                //  - even file objects have different rules (pipe names can contain most characters)
                //
                // As such we will do no further analysis of extended paths to avoid blocking known and unknown
                // scenarios as well as minimizing compat breaks should we block now and need to unblock later.
                return path;
            }

            bool isDevice = PathInternal.IsDevice(path);
            if (!isDevice)
            {
                // Toss out paths with colons that aren't a valid drive specifier.
                // Cannot start with a colon and can only be of the form "C:".
                // (Note that we used to explicitly check "http:" and "file:"- these are caught by this check now.)
                int startIndex = PathInternal.PathStartSkip(path);

                // Move past the colon
                startIndex += 2;

                if ((path.Length > 0 && path[0] == VolumeSeparatorChar)
                    || (path.Length >= startIndex && path[startIndex - 1] == VolumeSeparatorChar && !PathInternal.IsValidDriveChar(path[startIndex - 2]))
                    || (path.Length > startIndex && path.IndexOf(VolumeSeparatorChar, startIndex) != -1))
                {
                    throw new NotSupportedException(SR.Argument_PathFormatNotSupported);
                }
            }

            // Technically this doesn't matter but we used to throw for this case
            if (string.IsNullOrWhiteSpace(path))
                throw new ArgumentException(SR.Arg_PathIllegal);

            // We don't want to check invalid characters for device format- see comments for extended above
            string fullPath = PathHelper.Normalize(path, checkInvalidCharacters: !isDevice, expandShortPaths: true);

            if (!isDevice)
            {
                // Emulate FileIOPermissions checks, retained for compatibility (normal invalid characters have already been checked)
                if (PathInternal.HasWildCardCharacters(fullPath))
                    throw new ArgumentException(SR.Argument_InvalidPathChars, nameof(path));
            }

            return fullPath;
        }

        public static string GetTempPath()
        {
            StringBuilder sb = StringBuilderCache.Acquire(MaxPath);
            uint r = Interop.mincore.GetTempPathW(MaxPath, sb);
            if (r == 0)
                throw Win32Marshal.GetExceptionForLastWin32Error();
            return GetFullPath(StringBuilderCache.GetStringAndRelease(sb));
        }

        // Returns a unique temporary file name, and creates a 0-byte file by that
        // name on disk.
        public static string GetTempFileName()
        {
            string path = GetTempPath();

            StringBuilder sb = StringBuilderCache.Acquire(MaxPath);
            uint r = Interop.mincore.GetTempFileNameW(path, "tmp", 0, sb);
            if (r == 0)
                throw Win32Marshal.GetExceptionForLastWin32Error();
            return StringBuilderCache.GetStringAndRelease(sb);
        }

        // Tests if the given path contains a root. A path is considered rooted
        // if it starts with a backslash ("\") or a drive letter and a colon (":").
        public static bool IsPathRooted(string path)
        {
            if (path != null)
            {
                PathInternal.CheckInvalidPathChars(path);

                int length = path.Length;
                if ((length >= 1 && PathInternal.IsDirectorySeparator(path[0])) ||
                    (length >= 2 && path[1] == VolumeSeparatorChar))
                    return true;
            }
            return false;
        }

        // Returns the root portion of the given path. The resulting string
        // consists of those rightmost characters of the path that constitute the
        // root of the path. Possible patterns for the resulting string are: An
        // empty string (a relative path on the current drive), "\" (an absolute
        // path on the current drive), "X:" (a relative path on a given drive,
        // where X is the drive letter), "X:\" (an absolute path on a given drive),
        // and "\\server\share" (a UNC path for a given server and share name).
        // The resulting string is null if path is null.
        public static string GetPathRoot(string path)
        {
            if (path == null) return null;
            PathInternal.CheckInvalidPathChars(path);

            // Need to return the normalized directory separator
            path = PathInternal.NormalizeDirectorySeparators(path);

            int pathRoot = PathInternal.GetRootLength(path);
            return pathRoot <= 0 ? string.Empty : path.Substring(0, pathRoot);
        }
    }
}


text:
class Admin::EventsController < ApplicationController
  include AlchemyContentable::AdminControllerMixin
end


text:
<?php

return function() {

  $translations = array();

  foreach(panel()->translations() as $translation) {
    $translations[$translation->code()] = $translation->title();
  }

  $form = new Kirby\Panel\Form(array(

    'username' => array(
      'label'        => 'installation.signup.username.label',
      'type'         => 'text',
      'icon'         => 'user',
      'placeholder'  => 'installation.signup.username.placeholder',
      'required'     => true,
      'autocomplete' => false,
      'autofocus'    => true,
    ),

    'password' => array(
      'label'        => 'installation.signup.password.label',
      'type'         => 'password',
      'required'     => true,
      'autocomplete' => false,
      'suggestion'   => true,
    ),

    'email' => array(
      'label'        => 'installation.signup.email.label',
      'placeholder'  => 'installation.signup.email.placeholder',
      'type'         => 'email',
      'required'     => true,
      'autocomplete' => false,
    ),

    'language' => array(
      'label'        => 'installation.signup.language.label',
      'type'         => 'select',
      'required'     => true,
      'autocomplete' => false,
      'default'      => kirby()->option('panel.language', 'en'),
      'options'      => $translations
    )

  ));

  $form->attr('autocomplete', 'off');
  $form->data('autosubmit', 'native');
  $form->style('centered');

  $form->buttons->submit->value = l('installation.signup.button');

  return $form;

};


text:
require 'spec_helper'

module Apilint
  describe Linter do
  end
end


text:
/**
 * Field value parsing for the standard Java compiler.
 */
package org.springframework.boot.configurationprocessor.fieldvalues.javac;


text:
<?php
namespace Acelaya\Service;

use League\Flysystem\FilesystemInterface;
use Psr\Log\AbstractLogger;
use Psr\Log\LoggerInterface;

/**
 * This logger does nothing
 *
 * Class Logger
 * @author
 * @link
 */
class Logger extends AbstractLogger
{
    /**
     * @var FilesystemInterface
     */
    protected $filesystem;
    /**
     * @var string
     */
    protected $filename;

    /**
     * @param FilesystemInterface $filesystem
     * @param $filename
     */
    public function __construct(FilesystemInterface $filesystem, $filename)
    {
        $this->filesystem = $filesystem;
        $this->filename = $filename;
    }

    /**
     * Logs with an arbitrary level.
     *
     * @param mixed $level
     * @param string $message
     * @param array $context
     * @return null
     */
    public function log($level, $message, array $context = array())
    {
        $this->filesystem->put($this->filename, $this->createMessage($level, $message));
    }

    protected function createMessage($level, $message)
    {
        return sprintf('[%s] [%s] - %s', $level, date('Y-m-d H:i:s'), $message);
    }
}


text:
#include "testApp.h"

testApp::testApp()
	:gui("Settings", 300)
	,app(ofGetWidth(), ofGetHeight())
{
	printf("Test app.cpp\n");
}

//--------------------------------------------------------------
void testApp::setup(){
	ofBackground(3);
	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	ofEnableNormalizedTexCoords();
	show_gui = true;
	debug = true;
	app.setup();

	gui.addFloat("Flock high threshold (align)", app.flock.high).setMin(0.0f).setMax(1.0f);
	gui.addFloat("Flock low threshold (separate)", app.flock.low).setMin(0.0f).setMax(1.0f);
	gui.addFloat("Flock radius SQ", app.flock.zone_radius_sq).setMin(0.0f).setMax(20000.0f);
	gui.addFloat("Flock max speed", settings.flocking_max_speed).setMin(0.0f).setMax(50.0f).setColor(0.6,0.1,0.1);
	gui.addFloat("Flock align energy", app.flock.align_energy).setMin(0.0f).setMax(100.0f);
	gui.addFloat("Flock separate energy", app.flock.separate_energy).setMin(0.0f).setMax(100.0f);
	gui.addFloat("Flock attract energy", app.flock.attract_energy).setMin(0.0f).setMax(100.0f);
	gui.addBool("Flock apply perlin noise", settings.flocking_apply_perlin);//.setColor(0.4, 0.03, 0.1);
	gui.addFloat("Flock perlin scale", settings.flocking_perlin_scale).setMin(0.0f).setMax(10.0f); //.setColor(0.4, 0.03, 0.1);
	gui.addFloat("Flock perlin influence", settings.flocking_perlin_influence).setMin(0.0f).setMax(100.0f); //.setColor(0.4, 0.03, 0.1);
	gui.addFloat("Player repel energy", settings.player_repel_energy).setMin(0.0f).setMax(100000.0f).setColor(0.1,0.4,0.0);
	gui.addFloat("Player repel radius", settings.player_repel_radius).setMin(0.0f).setMax(1000.0f).setColor(0.1,0.4,0.0);

	gui.addFloat("Boid trail duration (millis)", settings.boid_trail_duration_millis).setMin(0.0f).setMax(5000.0f);
	gui.addFloat("Boid glow duration (millis)", settings.boid_glow_duration_millis).setMin(0.0f).setMax(5000.0f);

	gui.addFloat("Explosion random x velocity", settings.explosion_random_x_vel).setMin(0.0f).setMax(15.0f);
	gui.addFloat("Explosion random y velocity", settings.explosion_random_y_vel).setMin(0.0f).setMax(15.0f);
	gui.addFloat("Explosion min lifespan", settings.explosion_min_lifespan).setMin(0.0f).setMax(100.0f);
	gui.addFloat("Explosion max lifespan", settings.explosion_max_lifespan).setMin(0.0f).setMax(100.0f);
	gui.addFloat("Explosion perlin scale", settings.explosion_perlin_scale).setMin(0.0f).setMax(10.0f);
	gui.addFloat("Explosion perlin influence", settings.explosion_perlin_influence).setMin(0.0f).setMax(1.0f);
	gui.addInt("Explosion trail length", settings.explosion_trail_length).setMin(0).setMax(20);

	//gui.load(ofToDataPath("gui.bin",true));

	/*
	cam.orthoTopLeft(ofGetWidth(), ofGetHeight(), 0.01f, 100.0f);
	cam.translate(0,0,5);
	*/
//	cam.orthoBottomLeft(ofGetWidth(), ofGetHeight(), 0.0, 100.0f);
}

//--------------------------------------------------------------
void testApp::update(){
	gui.update();
	app.update();
}

//--------------------------------------------------------------
void testApp::draw(){
	/*
	ofColor start_color(33,33,53);
	ofBackgroundGradient(start_color, ofColor::black, OF_GRADIENT_CIRCULAR);
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluPerspective(45.0f, ofGetWidth()/ofGetHeight(), 0.1, 100);

		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		glTranslatef(0,0,-10);
	//	app.debugDraw();
		return;
		*/
//	if(!debug) {
		Mat3 nm(cam.vm());
        nm.inverse();
        nm.transpose();

		app.draw(cam.pm(), cam.vm(), nm);
//	}
//	else {

//	}

	if(show_gui) {
		gui.draw();
	}
	/*
	//ofDrawBitmapString("Particles: " +ofToString(app.fx_ps.size()), 10, ofGetHeight()-40);
	ofDrawBitmapString(ofToString(ofGetFrameRate()), 10, ofGetHeight()-20);
	*/
}

//--------------------------------------------------------------
void testApp::keyPressed(int key){
	if(key == 'd') {
		debug = !debug;
	}
	else if(key == 's') {
	//	gui.save(ofToDataPath("gui.bin", true));
	}
	else if(key == 'l') {
	//	gui.load(ofToDataPath("gui.bin",true));
	}
	else if(key == 'g') {
		show_gui = !show_gui;
	}
}

//--------------------------------------------------------------
void testApp::keyReleased(int key){

}

//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y){
	gui.onMouseMoved(x,y);
}

//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
	gui.onMouseMoved(x,y);
}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
	gui.onMouseDown(x,y);
}

//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
	gui.onMouseUp(x,y);
}

//--------------------------------------------------------------
void testApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){

}


text:
/*
 * This file provided by Facebook is for non-commercial testing and evaluation
 * purposes only.  Facebook reserves all rights not expressly granted.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package com.facebook.fresco.samples.showcase;

import java.util.HashSet;
import java.util.Set;

import android.app.Application;

import com.facebook.common.internal.Supplier;
import com.facebook.common.logging.FLog;
import com.facebook.drawee.backends.pipeline.DraweeConfig;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.fresco.samples.showcase.misc.DebugOverlaySupplierSingleton;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.facebook.imagepipeline.listener.RequestListener;
import com.facebook.imagepipeline.listener.RequestLoggingListener;

/**
 * Showcase Application implementation where we set up Fresco
 */
public class ShowcaseApplication extends Application {

  @Override
  public void onCreate() {
    super.onCreate();
    FLog.setMinimumLoggingLevel(FLog.VERBOSE);
    Set<RequestListener> listeners = new HashSet<>();
    listeners.add(new RequestLoggingListener());

    ImagePipelineConfig imagePipelineConfig = ImagePipelineConfig.newBuilder(this)
        .setRequestListeners(listeners)
        .setImageDecoderConfig(CustomImageFormatConfigurator.createImageDecoderConfig(this))
        .experiment().setMediaVariationsIndexEnabled(new Supplier<Boolean>() {
          @Override
          public Boolean get() {
            return true;
          }
        })
        .build();

    DraweeConfig.Builder draweeConfigBuilder = DraweeConfig.newBuilder();
    CustomImageFormatConfigurator.addCustomDrawableFactories(this, draweeConfigBuilder);

    draweeConfigBuilder.setDebugOverlayEnabledSupplier(
        DebugOverlaySupplierSingleton.getInstance(getApplicationContext()));

    Fresco.initialize(this, imagePipelineConfig, draweeConfigBuilder.build());
  }
}


text:
export interface Expression {
	kind: string;
	op: string;
	left: Expression | string;
	right: Expression | any;
}

export declare function buildExpression(filterBy: { [key: string]: any }, op: string): Expression;