Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap-chain-python
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
cellframe
libdap-chain-python
Commits
1326c38b
Commit
1326c38b
authored
5 years ago
by
alexey.stratulat
Browse files
Options
Downloads
Patches
Plain Diff
[+] Added wrapping dap_chain_cs
parent
b8c86403
No related branches found
No related tags found
1 merge request
!1
Features 2564
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/wrapping_dap_chain_cs.h
+85
-0
85 additions, 0 deletions
include/wrapping_dap_chain_cs.h
src/wrapping_dap_chain_cs.c
+85
-0
85 additions, 0 deletions
src/wrapping_dap_chain_cs.c
with
170 additions
and
0 deletions
include/wrapping_dap_chain_cs.h
0 → 100644
+
85
−
0
View file @
1326c38b
#ifndef _WRAPPING_DAP_CHAIN_CS_
#define _WRAPPING_DAP_CHAIN_CS_
#include
"Python.h"
#include
"dap_chain_cs.h"
#include
"libdap-chain-python.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
PyDapChainCs
{
PyObject_HEAD
dap_chain_cs_t
*
cs
;
dap_chain_callback_new_cfg_t
callback_new_cfg
;
}
PyDapChainCsObject
;
static
PyObject
*
binded_object_callback_new_cfg
=
NULL
;
PyObject
*
DapChainCSObject_new
(
PyTypeObject
*
type_object
,
PyObject
*
args
,
PyObject
*
kwds
);
int
dap_chain_cs_init_py
(
void
);
void
dap_chain_cs_deinit_py
(
void
);
PyObject
*
dap_chain_cs_add_py
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_cs_create_py
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_class_add_py
(
PyObject
*
self
,
PyObject
*
args
);
PyObject
*
dap_chain_class_create_py
(
PyObject
*
self
,
PyObject
*
args
);
static
PyMethodDef
DapChainTypeMethods
[]
=
{
{
"csAdd"
,
(
PyCFunction
)
dap_chain_cs_add_py
,
METH_VARARGS
,
""
},
{
"csCreate"
,
(
PyCFunction
)
dap_chain_cs_create_py
,
METH_VARARGS
,
""
},
{
"classAdd"
,
(
PyCFunction
)
dap_chain_class_add_py
,
METH_VARARGS
,
""
},
{
"classCreate"
,
(
PyCFunction
)
dap_chain_class_create_py
,
METH_VARARGS
,
""
},
{
NULL
,
NULL
,
0
,
NULL
}
};
static
PyTypeObject
DapChainCsObject_DapChainCsObjectType
=
{
PyVarObject_HEAD_INIT
(
NULL
,
0
)
"CellFrame.ChainCS"
,
/* tp_name */
sizeof
(
PyDapChainCsObject
),
/* tp_basicsize */
0
,
/* tp_itemsize */
0
,
/* tp_dealloc */
0
,
/* tp_print */
0
,
/* tp_getattr */
0
,
/* tp_setattr */
0
,
/* tp_reserved */
0
,
/* tp_repr */
0
,
/* tp_as_number */
0
,
/* tp_as_sequence */
0
,
/* tp_as_mapping */
0
,
/* tp_hash */
0
,
/* tp_call */
0
,
/* tp_str */
0
,
/* tp_getattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
"Chain id object"
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
0
,
/* tp_iternext */
0
,
/* tp_methods */
0
,
/* tp_members */
0
,
/* tp_getset */
0
,
/* tp_base */
0
,
/* tp_dict */
0
,
/* tp_descr_get */
0
,
/* tp_descr_set */
0
,
/* tp_dictoffset */
0
,
/* tp_init */
0
,
/* tp_alloc */
DapChainCSObject_new
,
/* tp_new */
};
#ifdef __cplusplus
}
#endif
#endif //_WRAPPING_DAP_CHAIN_CS_
This diff is collapsed.
Click to expand it.
src/wrapping_dap_chain_cs.c
0 → 100644
+
85
−
0
View file @
1326c38b
#include
"wrapping_dap_chain_cs.h"
/* Callback created */
static
int
wrapping_dap_chain_callback_new_cfg
(
dap_chain_t
*
chain
,
dap_config_t
*
cfg
)
{
PyObject
*
arglist
;
PyObject
*
result
;
PyObject
*
obj_chain
=
_PyObject_New
(
&
dapChainObject_dapChainType
);
((
PyDapChainObject
*
)
obj_chain
)
->
chain_t
=
chain
;
arglist
=
Py_BuildValue
(
"O"
,
obj_chain
);
result
=
PyObject_CallObject
(
binded_object_callback_new_cfg
,
arglist
);
Py_DECREF
(
arglist
);
int
r
=
-
1
;
if
(
PyLong_Check
(
result
)){
r
=
(
int
)
PyLong_AsLong
(
result
);
}
Py_DECREF
(
result
);
return
r
;
}
/*--------------------------------*/
int
dap_chain_cs_init_py
(
void
){
return
dap_chain_cs_init
();
}
void
dap_chain_cs_deinit_py
(
void
){
dap_chain_cs_deinit
();
}
PyObject
*
DapChainCSObject_new
(
PyTypeObject
*
type_object
,
PyObject
*
args
,
PyObject
*
kwds
)
{
PyDapChainCsObject
*
obj
=
(
PyDapChainCsObject
*
)
PyType_GenericNew
(
type_object
,
args
,
kwds
);
obj
->
callback_new_cfg
=
wrapping_dap_chain_callback_new_cfg
;
return
(
PyObject
*
)
obj
;
}
PyObject
*
dap_chain_cs_add_py
(
PyObject
*
self
,
PyObject
*
args
){
const
char
*
cs_str
;
PyObject
*
obj_callback_init
;
if
(
!
PyArg_ParseTuple
(
args
,
"s|O:set_callback"
,
&
cs_str
,
&
obj_callback_init
)){
return
NULL
;
}
else
{
if
(
!
PyCallable_Check
(
obj_callback_init
))
{
PyErr_SetString
(
PyExc_TypeError
,
"paramentr must be callable"
);
return
NULL
;
}
}
Py_XINCREF
(
obj_callback_init
);
Py_XDECREF
(
binded_object_callback_new_cfg
);
binded_object_callback_new_cfg
=
obj_callback_init
;
dap_chain_cs_add
(
cs_str
,
((
PyDapChainCsObject
*
)
self
)
->
callback_new_cfg
);
return
PyLong_FromLong
(
0
);
}
PyObject
*
dap_chain_cs_create_py
(
PyObject
*
self
,
PyObject
*
args
){
PyObject
*
obj_chain
;
if
(
!
PyArg_ParseTuple
(
args
,
"O"
,
&
obj_chain
))
return
NULL
;
int
res
=
dap_chain_cs_create
(((
PyDapChainObject
*
)
obj_chain
)
->
chain_t
,
g_config
);
return
PyLong_FromLong
(
res
);
}
PyObject
*
dap_chain_class_add_py
(
PyObject
*
self
,
PyObject
*
args
){
const
char
*
cs_str
;
PyObject
*
obj_callback_init
;
if
(
!
PyArg_ParseTuple
(
args
,
"s|O:set_callback"
,
&
cs_str
,
&
obj_callback_init
)){
return
NULL
;
}
else
{
if
(
!
PyCallable_Check
(
obj_callback_init
))
{
PyErr_SetString
(
PyExc_TypeError
,
"paramentr must be callable"
);
return
NULL
;
}
}
Py_XINCREF
(
obj_callback_init
);
Py_XDECREF
(
binded_object_callback_new_cfg
);
binded_object_callback_new_cfg
=
obj_callback_init
;
dap_chain_class_add
(
cs_str
,
((
PyDapChainCsObject
*
)
self
)
->
callback_new_cfg
);
return
PyLong_FromLong
(
0
);
}
PyObject
*
dap_chain_class_create_py
(
PyObject
*
self
,
PyObject
*
args
){
PyObject
*
obj_chain
;
if
(
!
PyArg_ParseTuple
(
args
,
"O"
,
&
obj_chain
))
return
NULL
;
int
res
=
dap_chain_class_create
(((
PyDapChainObject
*
)
obj_chain
)
->
chain_t
,
g_config
);
return
PyLong_FromLong
(
res
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment