Пример #1
0
This module provides some functions for accessing win32 exe resources from
rpython code.  It's a trimmed-down version of the esky.winres module with
just enough functionality to get the py2exe compiled bootstrapper working.

"""

from pypy.rlib import libffi
from pypy.rpython.lltypesystem import rffi, lltype
from pypy.rlib import rwin32


LOAD_LIBRARY_AS_DATAFILE = 0x00000002


k32_LoadLibraryExA = rwin32.winexternal("LoadLibraryExA",[rffi.CCHARP,rwin32.HANDLE,rwin32.DWORD],rwin32.HANDLE)
k32_FindResourceExA = rwin32.winexternal("FindResourceExA",[rwin32.HANDLE,rffi.CCHARP,rwin32.DWORD,rwin32.DWORD],rwin32.HANDLE)
k32_SizeofResource = rwin32.winexternal("SizeofResource",[rwin32.HANDLE,rwin32.HANDLE],rwin32.DWORD)
k32_LoadResource = rwin32.winexternal("LoadResource",[rwin32.HANDLE,rwin32.HANDLE],rwin32.HANDLE)
k32_LockResource = rwin32.winexternal("LockResource",[rwin32.HANDLE],rffi.CCHARP)
k32_FreeLibrary = rwin32.winexternal("FreeLibrary",[rwin32.HANDLE],rwin32.BOOL)

def load_resource(filename,resname,resid,reslang):
    """Load the named resource from the given file.

    The filename and resource name must be ascii strings, and the resid and
    reslang must be integers.
    """
    l_handle = k32_LoadLibraryExA(filename,0,LOAD_LIBRARY_AS_DATAFILE)
    if not l_handle:
        raise WindowsError(rwin32.GetLastError(),"LoadLibraryExW failed")
Пример #2
0
from pypy.rpython.tool import rffi_platform as platform
from pypy.module.thread import ll_thread
from pypy.module._multiprocessing.interp_connection import w_handle
import sys, os, time, errno

RECURSIVE_MUTEX, SEMAPHORE = range(2)

if sys.platform == 'win32':
    from pypy.rlib import rwin32
    from pypy.module._multiprocessing.interp_win32 import (
        handle_w, _GetTickCount)

    SEM_VALUE_MAX = sys.maxint

    _CreateSemaphore = rwin32.winexternal(
        'CreateSemaphoreA', [rffi.VOIDP, rffi.LONG, rffi.LONG, rwin32.LPCSTR],
        rwin32.HANDLE)
    _ReleaseSemaphore = rwin32.winexternal(
        'ReleaseSemaphore', [rwin32.HANDLE, rffi.LONG, rffi.LONGP],
        rwin32.BOOL)

else:
    from pypy.rlib import rposix

    if sys.platform == 'darwin':
        libraries = []
    else:
        libraries = ['rt']

    eci = ExternalCompilationInfo(
        includes = ['sys/time.h',
Пример #3
0
from pypy.rpython.tool import rffi_platform as platform
from pypy.module.thread import ll_thread
from pypy.module._multiprocessing.interp_connection import w_handle
import sys, os, time, errno

RECURSIVE_MUTEX, SEMAPHORE = range(2)

if sys.platform == 'win32':
    from pypy.rlib import rwin32
    from pypy.module._multiprocessing.interp_win32 import (
        handle_w, _GetTickCount)

    SEM_VALUE_MAX = sys.maxint

    _CreateSemaphore = rwin32.winexternal(
        'CreateSemaphoreA', [rffi.VOIDP, rffi.LONG, rffi.LONG, rwin32.LPCSTR],
        rwin32.HANDLE)
    _CloseHandle = rwin32.winexternal('CloseHandle', [rwin32.HANDLE],
        rwin32.BOOL, threadsafe=False)
    _ReleaseSemaphore = rwin32.winexternal(
        'ReleaseSemaphore', [rwin32.HANDLE, rffi.LONG, rffi.LONGP],
        rwin32.BOOL)

else:
    from pypy.rlib import rposix

    if sys.platform == 'darwin':
        libraries = []
    else:
        libraries = ['rt']
Пример #4
0
from pypy.rpython.tool import rffi_platform as platform
from pypy.module.thread import ll_thread
from pypy.module._multiprocessing.interp_connection import w_handle
import sys, os, time, errno

RECURSIVE_MUTEX, SEMAPHORE = range(2)

if sys.platform == 'win32':
    from pypy.rlib import rwin32
    from pypy.module._multiprocessing.interp_win32 import (handle_w,
                                                           _GetTickCount)

    SEM_VALUE_MAX = sys.maxint

    _CreateSemaphore = rwin32.winexternal(
        'CreateSemaphoreA', [rffi.VOIDP, rffi.LONG, rffi.LONG, rwin32.LPCSTR],
        rwin32.HANDLE)
    _CloseHandle = rwin32.winexternal('CloseHandle', [rwin32.HANDLE],
                                      rwin32.BOOL,
                                      threadsafe=False)
    _ReleaseSemaphore = rwin32.winexternal(
        'ReleaseSemaphore', [rwin32.HANDLE, rffi.LONG, rffi.LONGP],
        rwin32.BOOL)

else:
    from pypy.rlib import rposix

    if sys.platform == 'darwin':
        libraries = []
    else:
        libraries = ['rt']
Пример #5
0

This module provides some functions for accessing win32 exe resources from
rpython code.  It's a trimmed-down version of the esky.winres module with
just enough functionality to get the py2exe compiled bootstrapper working.

"""

from pypy.rlib import libffi
from pypy.rpython.lltypesystem import rffi, lltype
from pypy.rlib import rwin32

LOAD_LIBRARY_AS_DATAFILE = 0x00000002

k32_LoadLibraryExA = rwin32.winexternal(
    "LoadLibraryExA", [rffi.CCHARP, rwin32.HANDLE, rwin32.DWORD],
    rwin32.HANDLE)
k32_FindResourceExA = rwin32.winexternal(
    "FindResourceExA",
    [rwin32.HANDLE, rffi.CCHARP, rwin32.DWORD, rwin32.DWORD], rwin32.HANDLE)
k32_SizeofResource = rwin32.winexternal("SizeofResource",
                                        [rwin32.HANDLE, rwin32.HANDLE],
                                        rwin32.DWORD)
k32_LoadResource = rwin32.winexternal("LoadResource",
                                      [rwin32.HANDLE, rwin32.HANDLE],
                                      rwin32.HANDLE)
k32_LockResource = rwin32.winexternal("LockResource", [rwin32.HANDLE],
                                      rffi.CCHARP)
k32_FreeLibrary = rwin32.winexternal("FreeLibrary", [rwin32.HANDLE],
                                     rwin32.BOOL)
Пример #6
0
        libraries = ['kernel32'],
        )

    for name in CONSTANTS:
        locals()[name] = rffi_platform.ConstantInteger(name)

config = rffi_platform.configure(CConfig)
globals().update(config)

def handle_w(space, w_handle):
    return rffi.cast(rwin32.HANDLE, space.int_w(w_handle))

_CreateNamedPipe = rwin32.winexternal(
    'CreateNamedPipeA', [
        rwin32.LPCSTR,
        rwin32.DWORD, rwin32.DWORD, rwin32.DWORD,
        rwin32.DWORD, rwin32.DWORD, rwin32.DWORD,
        rffi.VOIDP],
    rwin32.HANDLE)

_ConnectNamedPipe = rwin32.winexternal(
    'ConnectNamedPipe', [rwin32.HANDLE, rffi.VOIDP], rwin32.BOOL)

_SetNamedPipeHandleState = rwin32.winexternal(
    'SetNamedPipeHandleState', [
        rwin32.HANDLE,
        rwin32.LPDWORD, rwin32.LPDWORD, rwin32.LPDWORD],
    rwin32.BOOL)

_WaitNamedPipe = rwin32.winexternal(
    'WaitNamedPipeA', [rwin32.LPCSTR, rwin32.DWORD],