Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
420ed403
Kaydet (Commit)
420ed403
authored
Ara 31, 2001
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added support for the Carbon scrap manager (finally).
üst
76335936
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
314 additions
and
75 deletions
+314
-75
_Scrapmodule.c
Mac/Modules/scrap/_Scrapmodule.c
+289
-73
scrapscan.py
Mac/Modules/scrap/scrapscan.py
+11
-2
scrapsupport.py
Mac/Modules/scrap/scrapsupport.py
+14
-0
No files found.
Mac/Modules/scrap/_Scrapmodule.c
Dosyayı görüntüle @
420ed403
/* =========================
= Module
Scrap ========================== */
/* =========================
Module _
Scrap ========================== */
#include "Python.h"
#include "Python.h"
#ifdef _WIN32
#include "pywintoolbox.h"
#else
#include "macglue.h"
#include "macglue.h"
#include "pymactoolbox.h"
#include "pymactoolbox.h"
#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
PyErr_SetString(PyExc_NotImplementedError, \
"Not available in this shared library/OS version"); \
return NULL; \
}} while(0)
#ifdef WITHOUT_FRAMEWORKS
#ifdef WITHOUT_FRAMEWORKS
#include <Scrap.h>
#include <Scrap.h>
...
@@ -14,7 +26,7 @@
...
@@ -14,7 +26,7 @@
#include <Carbon/Carbon.h>
#include <Carbon/Carbon.h>
#endif
#endif
#if
!TARGET_API_MAC_CARBON
#if
TARGET_API_MAC_OS8
/*
/*
** Generate ScrapInfo records
** Generate ScrapInfo records
...
@@ -32,9 +44,242 @@ SCRRec_New(itself)
...
@@ -32,9 +44,242 @@ SCRRec_New(itself)
static
PyObject
*
Scrap_Error
;
static
PyObject
*
Scrap_Error
;
static
PyObject
*
Scrap_LoadScrap
(
_self
,
_args
)
#if !TARGET_API_MAC_OS8
PyObject
*
_self
;
/* ----------------------- Object type Scrap ------------------------ */
PyObject
*
_args
;
PyTypeObject
Scrap_Type
;
#define ScrapObj_Check(x) ((x)->ob_type == &Scrap_Type)
typedef
struct
ScrapObject
{
PyObject_HEAD
ScrapRef
ob_itself
;
}
ScrapObject
;
PyObject
*
ScrapObj_New
(
ScrapRef
itself
)
{
ScrapObject
*
it
;
it
=
PyObject_NEW
(
ScrapObject
,
&
Scrap_Type
);
if
(
it
==
NULL
)
return
NULL
;
it
->
ob_itself
=
itself
;
return
(
PyObject
*
)
it
;
}
int
ScrapObj_Convert
(
PyObject
*
v
,
ScrapRef
*
p_itself
)
{
if
(
!
ScrapObj_Check
(
v
))
{
PyErr_SetString
(
PyExc_TypeError
,
"Scrap required"
);
return
0
;
}
*
p_itself
=
((
ScrapObject
*
)
v
)
->
ob_itself
;
return
1
;
}
static
void
ScrapObj_dealloc
(
ScrapObject
*
self
)
{
/* Cleanup of self->ob_itself goes here */
PyMem_DEL
(
self
);
}
static
PyObject
*
ScrapObj_GetScrapFlavorFlags
(
ScrapObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
ScrapFlavorType
flavorType
;
ScrapFlavorFlags
flavorFlags
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&"
,
PyMac_GetOSType
,
&
flavorType
))
return
NULL
;
_err
=
GetScrapFlavorFlags
(
_self
->
ob_itself
,
flavorType
,
&
flavorFlags
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
_res
=
Py_BuildValue
(
"l"
,
flavorFlags
);
return
_res
;
}
static
PyObject
*
ScrapObj_GetScrapFlavorSize
(
ScrapObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
ScrapFlavorType
flavorType
;
Size
byteCount
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&"
,
PyMac_GetOSType
,
&
flavorType
))
return
NULL
;
_err
=
GetScrapFlavorSize
(
_self
->
ob_itself
,
flavorType
,
&
byteCount
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
_res
=
Py_BuildValue
(
"l"
,
byteCount
);
return
_res
;
}
static
PyObject
*
ScrapObj_GetScrapFlavorData
(
ScrapObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
ScrapFlavorType
flavorType
;
Size
byteCount
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&"
,
PyMac_GetOSType
,
&
flavorType
))
return
NULL
;
_err
=
GetScrapFlavorSize
(
_self
->
ob_itself
,
flavorType
,
&
byteCount
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
_res
=
PyString_FromStringAndSize
(
NULL
,
(
int
)
byteCount
);
if
(
_res
==
NULL
)
return
NULL
;
_err
=
GetScrapFlavorData
(
_self
->
ob_itself
,
flavorType
,
&
byteCount
,
PyString_AS_STRING
(
_res
));
if
(
_err
!=
noErr
)
{
Py_XDECREF
(
_res
);
return
PyMac_Error
(
_err
);
}
destination__error__:
;
return
_res
;
}
static
PyObject
*
ScrapObj_PutScrapFlavor
(
ScrapObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
ScrapFlavorType
flavorType
;
ScrapFlavorFlags
flavorFlags
;
char
*
flavorData__in__
;
int
flavorData__in_len__
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&ls#"
,
PyMac_GetOSType
,
&
flavorType
,
&
flavorFlags
,
&
flavorData__in__
,
&
flavorData__in_len__
))
return
NULL
;
_err
=
PutScrapFlavor
(
_self
->
ob_itself
,
flavorType
,
flavorFlags
,
(
Size
)
flavorData__in_len__
,
flavorData__in__
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
flavorData__error__:
;
return
_res
;
}
static
PyObject
*
ScrapObj_GetScrapFlavorCount
(
ScrapObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
UInt32
infoCount
;
if
(
!
PyArg_ParseTuple
(
_args
,
""
))
return
NULL
;
_err
=
GetScrapFlavorCount
(
_self
->
ob_itself
,
&
infoCount
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
_res
=
Py_BuildValue
(
"l"
,
infoCount
);
return
_res
;
}
static
PyObject
*
ScrapObj_GetScrapFlavorInfoList
(
ScrapObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
PyObject
*
item
;
OSStatus
_err
;
UInt32
infoCount
;
ScrapFlavorInfo
*
infolist
=
NULL
;
int
i
;
if
(
!
PyArg_ParseTuple
(
_args
,
""
))
return
NULL
;
_err
=
GetScrapFlavorCount
(
_self
->
ob_itself
,
&
infoCount
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
if
(
infoCount
==
0
)
return
Py_BuildValue
(
"[]"
);
if
((
infolist
=
(
ScrapFlavorInfo
*
)
malloc
(
infoCount
*
sizeof
(
ScrapFlavorInfo
)))
==
NULL
)
return
PyErr_NoMemory
();
_err
=
GetScrapFlavorInfoList
(
_self
->
ob_itself
,
&
infoCount
,
infolist
);
if
(
_err
!=
noErr
)
{
free
(
infolist
);
return
NULL
;
}
if
((
_res
=
PyList_New
(
infoCount
))
==
NULL
)
{
free
(
infolist
);
return
NULL
;
}
for
(
i
=
0
;
i
<
infoCount
;
i
++
)
{
item
=
Py_BuildValue
(
"O&l"
,
PyMac_BuildOSType
,
infolist
[
i
].
flavorType
,
infolist
[
i
].
flavorFlags
);
if
(
!
item
||
PyList_SetItem
(
_res
,
i
,
item
)
<
0
)
{
Py_DECREF
(
_res
);
free
(
infolist
);
return
NULL
;
}
}
free
(
infolist
);
return
_res
;
}
static
PyMethodDef
ScrapObj_methods
[]
=
{
{
"GetScrapFlavorFlags"
,
(
PyCFunction
)
ScrapObj_GetScrapFlavorFlags
,
1
,
"(ScrapFlavorType flavorType) -> (ScrapFlavorFlags flavorFlags)"
},
{
"GetScrapFlavorSize"
,
(
PyCFunction
)
ScrapObj_GetScrapFlavorSize
,
1
,
"(ScrapFlavorType flavorType) -> (Size byteCount)"
},
{
"GetScrapFlavorData"
,
(
PyCFunction
)
ScrapObj_GetScrapFlavorData
,
1
,
"(ScrapFlavorType flavorType) -> string"
},
{
"PutScrapFlavor"
,
(
PyCFunction
)
ScrapObj_PutScrapFlavor
,
1
,
"(ScrapFlavorType flavorType, ScrapFlavorFlags flavorFlags, Buffer flavorData) -> None"
},
{
"GetScrapFlavorCount"
,
(
PyCFunction
)
ScrapObj_GetScrapFlavorCount
,
1
,
"() -> (UInt32 infoCount)"
},
{
"GetScrapFlavorInfoList"
,
(
PyCFunction
)
ScrapObj_GetScrapFlavorInfoList
,
1
,
"() -> ([(ScrapFlavorType, ScrapFlavorInfo), ...])"
},
{
NULL
,
NULL
,
0
}
};
PyMethodChain
ScrapObj_chain
=
{
ScrapObj_methods
,
NULL
};
static
PyObject
*
ScrapObj_getattr
(
ScrapObject
*
self
,
char
*
name
)
{
return
Py_FindMethodInChain
(
&
ScrapObj_chain
,
(
PyObject
*
)
self
,
name
);
}
#define ScrapObj_setattr NULL
#define ScrapObj_compare NULL
#define ScrapObj_repr NULL
#define ScrapObj_hash NULL
PyTypeObject
Scrap_Type
=
{
PyObject_HEAD_INIT
(
NULL
)
0
,
/*ob_size*/
"_Scrap.Scrap"
,
/*tp_name*/
sizeof
(
ScrapObject
),
/*tp_basicsize*/
0
,
/*tp_itemsize*/
/* methods */
(
destructor
)
ScrapObj_dealloc
,
/*tp_dealloc*/
0
,
/*tp_print*/
(
getattrfunc
)
ScrapObj_getattr
,
/*tp_getattr*/
(
setattrfunc
)
ScrapObj_setattr
,
/*tp_setattr*/
(
cmpfunc
)
ScrapObj_compare
,
/*tp_compare*/
(
reprfunc
)
ScrapObj_repr
,
/*tp_repr*/
(
PyNumberMethods
*
)
0
,
/* tp_as_number */
(
PySequenceMethods
*
)
0
,
/* tp_as_sequence */
(
PyMappingMethods
*
)
0
,
/* tp_as_mapping */
(
hashfunc
)
ScrapObj_hash
,
/*tp_hash*/
};
/* --------------------- End object type Scrap ---------------------- */
#endif
/* !TARGET_API_MAC_OS8 */
static
PyObject
*
Scrap_LoadScrap
(
PyObject
*
_self
,
PyObject
*
_args
)
{
{
PyObject
*
_res
=
NULL
;
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
OSStatus
_err
;
...
@@ -47,9 +292,7 @@ static PyObject *Scrap_LoadScrap(_self, _args)
...
@@ -47,9 +292,7 @@ static PyObject *Scrap_LoadScrap(_self, _args)
return
_res
;
return
_res
;
}
}
static
PyObject
*
Scrap_UnloadScrap
(
_self
,
_args
)
static
PyObject
*
Scrap_UnloadScrap
(
PyObject
*
_self
,
PyObject
*
_args
)
PyObject
*
_self
;
PyObject
*
_args
;
{
{
PyObject
*
_res
=
NULL
;
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
OSStatus
_err
;
...
@@ -62,11 +305,9 @@ static PyObject *Scrap_UnloadScrap(_self, _args)
...
@@ -62,11 +305,9 @@ static PyObject *Scrap_UnloadScrap(_self, _args)
return
_res
;
return
_res
;
}
}
#if
!TARGET_API_MAC_CARBON
#if
TARGET_API_MAC_OS8
static
PyObject
*
Scrap_InfoScrap
(
_self
,
_args
)
static
PyObject
*
Scrap_InfoScrap
(
PyObject
*
_self
,
PyObject
*
_args
)
PyObject
*
_self
;
PyObject
*
_args
;
{
{
PyObject
*
_res
=
NULL
;
PyObject
*
_res
=
NULL
;
ScrapStuffPtr
_rv
;
ScrapStuffPtr
_rv
;
...
@@ -77,13 +318,8 @@ static PyObject *Scrap_InfoScrap(_self, _args)
...
@@ -77,13 +318,8 @@ static PyObject *Scrap_InfoScrap(_self, _args)
SCRRec_New
,
_rv
);
SCRRec_New
,
_rv
);
return
_res
;
return
_res
;
}
}
#endif
#if !TARGET_API_MAC_CARBON
static
PyObject
*
Scrap_GetScrap
(
_self
,
_args
)
static
PyObject
*
Scrap_GetScrap
(
PyObject
*
_self
,
PyObject
*
_args
)
PyObject
*
_self
;
PyObject
*
_args
;
{
{
PyObject
*
_res
=
NULL
;
PyObject
*
_res
=
NULL
;
long
_rv
;
long
_rv
;
...
@@ -102,37 +338,21 @@ static PyObject *Scrap_GetScrap(_self, _args)
...
@@ -102,37 +338,21 @@ static PyObject *Scrap_GetScrap(_self, _args)
offset
);
offset
);
return
_res
;
return
_res
;
}
}
#endif
static
PyObject
*
Scrap_ZeroScrap
(
_self
,
_args
)
static
PyObject
*
Scrap_ZeroScrap
(
PyObject
*
_self
,
PyObject
*
_args
)
PyObject
*
_self
;
PyObject
*
_args
;
{
{
PyObject
*
_res
=
NULL
;
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
OSStatus
_err
;
if
(
!
PyArg_ParseTuple
(
_args
,
""
))
if
(
!
PyArg_ParseTuple
(
_args
,
""
))
return
NULL
;
return
NULL
;
#if TARGET_API_MAC_CARBON
{
ScrapRef
scrap
;
_err
=
ClearCurrentScrap
();
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
_err
=
GetCurrentScrap
(
&
scrap
);
}
#else
_err
=
ZeroScrap
();
_err
=
ZeroScrap
();
#endif
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
_res
=
Py_None
;
return
_res
;
return
_res
;
}
}
static
PyObject
*
Scrap_PutScrap
(
_self
,
_args
)
static
PyObject
*
Scrap_PutScrap
(
PyObject
*
_self
,
PyObject
*
_args
)
PyObject
*
_self
;
PyObject
*
_args
;
{
{
PyObject
*
_res
=
NULL
;
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
OSStatus
_err
;
...
@@ -141,37 +361,38 @@ static PyObject *Scrap_PutScrap(_self, _args)
...
@@ -141,37 +361,38 @@ static PyObject *Scrap_PutScrap(_self, _args)
char
*
sourceBuffer__in__
;
char
*
sourceBuffer__in__
;
int
sourceBuffer__len__
;
int
sourceBuffer__len__
;
int
sourceBuffer__in_len__
;
int
sourceBuffer__in_len__
;
#if TARGET_API_MAC_CARBON
if
(
!
PyArg_ParseTuple
(
_args
,
"lO&s#"
,
ScrapRef
scrap
;
&
sourceBufferByteCount
,
#endif
if
(
!
PyArg_ParseTuple
(
_args
,
"O&s#"
,
PyMac_GetOSType
,
&
flavorType
,
PyMac_GetOSType
,
&
flavorType
,
&
sourceBuffer__in__
,
&
sourceBuffer__in_len__
))
&
sourceBuffer__in__
,
&
sourceBuffer__in_len__
))
return
NULL
;
return
NULL
;
sourceBufferByteCount
=
sourceBuffer__in_len__
;
sourceBuffer__len__
=
sourceBuffer__in_len__
;
#if TARGET_API_MAC_CARBON
_err
=
GetCurrentScrap
(
&
scrap
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
_err
=
PutScrapFlavor
(
scrap
,
flavorType
,
0
,
sourceBufferByteCount
,
sourceBuffer__in__
);
#else
_err
=
PutScrap
(
sourceBufferByteCount
,
_err
=
PutScrap
(
sourceBufferByteCount
,
flavorType
,
flavorType
,
sourceBuffer__in__
);
sourceBuffer__in__
);
#endif
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
_res
=
Py_None
;
sourceBuffer__error__:
;
sourceBuffer__error__:
;
return
_res
;
return
_res
;
}
}
#endif
/* TARGET_API_MAC_OS8 */
#if TARGET_API_MAC_CARBON
#if !TARGET_API_MAC_OS8
static
PyObject
*
Scrap_GetCurrentScrap
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
ScrapRef
scrap
;
if
(
!
PyArg_ParseTuple
(
_args
,
""
))
return
NULL
;
_err
=
GetCurrentScrap
(
&
scrap
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
_res
=
Py_BuildValue
(
"O&"
,
ScrapObj_New
,
scrap
);
return
_res
;
}
static
PyObject
*
Scrap_ClearCurrentScrap
(
_self
,
_args
)
static
PyObject
*
Scrap_ClearCurrentScrap
(
PyObject
*
_self
,
PyObject
*
_args
)
PyObject
*
_self
;
PyObject
*
_args
;
{
{
PyObject
*
_res
=
NULL
;
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
OSStatus
_err
;
...
@@ -183,13 +404,8 @@ static PyObject *Scrap_ClearCurrentScrap(_self, _args)
...
@@ -183,13 +404,8 @@ static PyObject *Scrap_ClearCurrentScrap(_self, _args)
_res
=
Py_None
;
_res
=
Py_None
;
return
_res
;
return
_res
;
}
}
#endif
#if TARGET_API_MAC_CARBON
static
PyObject
*
Scrap_CallInScrapPromises
(
PyObject
*
_self
,
PyObject
*
_args
)
static
PyObject
*
Scrap_CallInScrapPromises
(
_self
,
_args
)
PyObject
*
_self
;
PyObject
*
_args
;
{
{
PyObject
*
_res
=
NULL
;
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
OSStatus
_err
;
...
@@ -209,28 +425,22 @@ static PyMethodDef Scrap_methods[] = {
...
@@ -209,28 +425,22 @@ static PyMethodDef Scrap_methods[] = {
{
"UnloadScrap"
,
(
PyCFunction
)
Scrap_UnloadScrap
,
1
,
{
"UnloadScrap"
,
(
PyCFunction
)
Scrap_UnloadScrap
,
1
,
"() -> None"
},
"() -> None"
},
#if
!TARGET_API_MAC_CARBON
#if
TARGET_API_MAC_OS8
{
"InfoScrap"
,
(
PyCFunction
)
Scrap_InfoScrap
,
1
,
{
"InfoScrap"
,
(
PyCFunction
)
Scrap_InfoScrap
,
1
,
"() -> (ScrapStuffPtr _rv)"
},
"() -> (ScrapStuffPtr _rv)"
},
#endif
#if !TARGET_API_MAC_CARBON
{
"GetScrap"
,
(
PyCFunction
)
Scrap_GetScrap
,
1
,
{
"GetScrap"
,
(
PyCFunction
)
Scrap_GetScrap
,
1
,
"(Handle destination, ScrapFlavorType flavorType) -> (long _rv, SInt32 offset)"
},
"(Handle destination, ScrapFlavorType flavorType) -> (long _rv, SInt32 offset)"
},
#endif
{
"ZeroScrap"
,
(
PyCFunction
)
Scrap_ZeroScrap
,
1
,
{
"ZeroScrap"
,
(
PyCFunction
)
Scrap_ZeroScrap
,
1
,
"() -> None"
},
"() -> None"
},
{
"PutScrap"
,
(
PyCFunction
)
Scrap_PutScrap
,
1
,
{
"PutScrap"
,
(
PyCFunction
)
Scrap_PutScrap
,
1
,
"(ScrapFlavorType flavorType, Buffer sourceBuffer) -> None"
},
"(SInt32 sourceBufferByteCount, ScrapFlavorType flavorType, Buffer sourceBuffer) -> None"
},
#endif
#if TARGET_API_MAC_CARBON
#if !TARGET_API_MAC_OS8
{
"GetCurrentScrap"
,
(
PyCFunction
)
Scrap_GetCurrentScrap
,
1
,
"() -> (ScrapRef scrap)"
},
{
"ClearCurrentScrap"
,
(
PyCFunction
)
Scrap_ClearCurrentScrap
,
1
,
{
"ClearCurrentScrap"
,
(
PyCFunction
)
Scrap_ClearCurrentScrap
,
1
,
"() -> None"
},
"() -> None"
},
#endif
#if TARGET_API_MAC_CARBON
{
"CallInScrapPromises"
,
(
PyCFunction
)
Scrap_CallInScrapPromises
,
1
,
{
"CallInScrapPromises"
,
(
PyCFunction
)
Scrap_CallInScrapPromises
,
1
,
"() -> None"
},
"() -> None"
},
#endif
#endif
...
@@ -240,7 +450,7 @@ static PyMethodDef Scrap_methods[] = {
...
@@ -240,7 +450,7 @@ static PyMethodDef Scrap_methods[] = {
void
init_Scrap
()
void
init_Scrap
(
void
)
{
{
PyObject
*
m
;
PyObject
*
m
;
PyObject
*
d
;
PyObject
*
d
;
...
@@ -254,7 +464,13 @@ void init_Scrap()
...
@@ -254,7 +464,13 @@ void init_Scrap()
if
(
Scrap_Error
==
NULL
||
if
(
Scrap_Error
==
NULL
||
PyDict_SetItemString
(
d
,
"Error"
,
Scrap_Error
)
!=
0
)
PyDict_SetItemString
(
d
,
"Error"
,
Scrap_Error
)
!=
0
)
return
;
return
;
#if !TARGET_API_MAC_OS8
Scrap_Type
.
ob_type
=
&
PyType_Type
;
Py_INCREF
(
&
Scrap_Type
);
if
(
PyDict_SetItemString
(
d
,
"ScrapType"
,
(
PyObject
*
)
&
Scrap_Type
)
!=
0
)
Py_FatalError
(
"can't initialize ScrapType"
);
#endif
}
}
/* =======================
= End module
Scrap ======================== */
/* =======================
End module _
Scrap ======================== */
Mac/Modules/scrap/scrapscan.py
Dosyayı görüntüle @
420ed403
...
@@ -5,7 +5,10 @@
...
@@ -5,7 +5,10 @@
import
sys
import
sys
import
os
import
os
BGENDIR
=
os
.
path
.
join
(
sys
.
prefix
,
':Tools:bgen:bgen'
)
if
os
.
sep
==
':'
:
BGENDIR
=
os
.
path
.
join
(
sys
.
prefix
,
':Tools:bgen:bgen'
)
else
:
BGENDIR
=
"../../../Tools/bgen/bgen"
sys
.
path
.
append
(
BGENDIR
)
sys
.
path
.
append
(
BGENDIR
)
from
scantools
import
Scanner
from
scantools
import
Scanner
from
bgenlocations
import
TOOLBOXDIR
from
bgenlocations
import
TOOLBOXDIR
...
@@ -29,10 +32,16 @@ class MyScanner(Scanner):
...
@@ -29,10 +32,16 @@ class MyScanner(Scanner):
def
destination
(
self
,
type
,
name
,
arglist
):
def
destination
(
self
,
type
,
name
,
arglist
):
classname
=
"Function"
classname
=
"Function"
listname
=
"functions"
listname
=
"functions"
if
arglist
:
t
,
n
,
m
=
arglist
[
0
]
if
t
==
'ScrapRef'
and
m
==
"InMode"
:
classname
=
"Method"
listname
=
"methods"
return
classname
,
listname
return
classname
,
listname
def
makeblacklistnames
(
self
):
def
makeblacklistnames
(
self
):
return
[
return
[
"GetScrapFlavorInfoList"
,
]
]
def
makegreylist
(
self
):
def
makegreylist
(
self
):
...
@@ -50,7 +59,7 @@ class MyScanner(Scanner):
...
@@ -50,7 +59,7 @@ class MyScanner(Scanner):
def
makeblacklisttypes
(
self
):
def
makeblacklisttypes
(
self
):
return
[
return
[
"ScrapRef"
,
# For now -- This is the Carbon scrap main object
'ScrapPromiseKeeperUPP'
,
]
]
def
makerepairinstructions
(
self
):
def
makerepairinstructions
(
self
):
...
...
Mac/Modules/scrap/scrapsupport.py
Dosyayı görüntüle @
420ed403
...
@@ -11,15 +11,19 @@ import string
...
@@ -11,15 +11,19 @@ import string
# Declarations that change for each manager
# Declarations that change for each manager
MACHEADERFILE
=
'Scrap.h'
# The Apple header file
MACHEADERFILE
=
'Scrap.h'
# The Apple header file
MODNAME
=
'_Scrap'
# The name of the module
MODNAME
=
'_Scrap'
# The name of the module
OBJECTNAME
=
'Scrap'
# The basic name of the objects used here
# The following is *usually* unchanged but may still require tuning
# The following is *usually* unchanged but may still require tuning
MODPREFIX
=
'Scrap'
# The prefix for module-wide routines
MODPREFIX
=
'Scrap'
# The prefix for module-wide routines
OBJECTTYPE
=
OBJECTNAME
+
'Ref'
# The C type used to represent them
OBJECTPREFIX
=
MODPREFIX
+
'Obj'
# The prefix for object methods
INPUTFILE
=
string
.
lower
(
MODPREFIX
)
+
'gen.py'
# The file generated by the scanner
INPUTFILE
=
string
.
lower
(
MODPREFIX
)
+
'gen.py'
# The file generated by the scanner
OUTPUTFILE
=
'@'
+
MODNAME
+
"module.c"
# The file generated by this program
OUTPUTFILE
=
'@'
+
MODNAME
+
"module.c"
# The file generated by this program
from
macsupport
import
*
from
macsupport
import
*
# Create the type objects
# Create the type objects
ScrapRef
=
OpaqueByValueType
(
OBJECTTYPE
,
OBJECTPREFIX
)
includestuff
=
includestuff
+
"""
includestuff
=
includestuff
+
"""
#ifdef WITHOUT_FRAMEWORKS
#ifdef WITHOUT_FRAMEWORKS
...
@@ -44,21 +48,31 @@ SCRRec_New(itself)
...
@@ -44,21 +48,31 @@ SCRRec_New(itself)
ScrapStuffPtr
=
OpaqueByValueType
(
'ScrapStuffPtr'
,
'SCRRec'
)
ScrapStuffPtr
=
OpaqueByValueType
(
'ScrapStuffPtr'
,
'SCRRec'
)
ScrapFlavorType
=
OSTypeType
(
'ScrapFlavorType'
)
ScrapFlavorType
=
OSTypeType
(
'ScrapFlavorType'
)
ScrapFlavorFlags
=
Type
(
'ScrapFlavorFlags'
,
'l'
)
#ScrapFlavorInfo = OpaqueType('ScrapFlavorInfo', 'ScrapFlavorInfo')
putscrapbuffer
=
FixedInputBufferType
(
'void *'
)
putscrapbuffer
=
FixedInputBufferType
(
'void *'
)
class
MyObjectDefinition
(
GlobalObjectDefinition
):
pass
# Create the generator groups and link them
# Create the generator groups and link them
module
=
MacModule
(
MODNAME
,
MODPREFIX
,
includestuff
,
finalstuff
,
initstuff
)
module
=
MacModule
(
MODNAME
,
MODPREFIX
,
includestuff
,
finalstuff
,
initstuff
)
object
=
MyObjectDefinition
(
OBJECTNAME
,
OBJECTPREFIX
,
OBJECTTYPE
)
module
.
addobject
(
object
)
# Create the generator classes used to populate the lists
# Create the generator classes used to populate the lists
Function
=
OSErrFunctionGenerator
Function
=
OSErrFunctionGenerator
Method
=
OSErrMethodGenerator
# Create and populate the lists
# Create and populate the lists
functions
=
[]
functions
=
[]
methods
=
[]
execfile
(
INPUTFILE
)
execfile
(
INPUTFILE
)
# add the populated lists to the generator groups
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
# (in a different wordl the scan program would generate this)
for
f
in
functions
:
module
.
add
(
f
)
for
f
in
functions
:
module
.
add
(
f
)
for
f
in
methods
:
object
.
add
(
f
)
# generate output (open the output file as late as possible)
# generate output (open the output file as late as possible)
SetOutputFileName
(
OUTPUTFILE
)
SetOutputFileName
(
OUTPUTFILE
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment