Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hammer
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
Show more breadcrumbs
Letitia Li
hammer
Commits
8b4b8ddc
Commit
8b4b8ddc
authored
5 years ago
by
Alex Willmer
Browse files
Options
Downloads
Patches
Plain Diff
Use PyBytes_* Python CAPI functions
This removes any doubts about what type of string is in use.
parent
c8239094
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bindings/swig/hammer.i
+6
-3
6 additions, 3 deletions
src/bindings/swig/hammer.i
with
6 additions
and
3 deletions
src/bindings/swig/hammer.i
+
6
−
3
View file @
8b4b8ddc
%
module
hammer
%
module
hammer
%
begin
%
{
#define SWIG_PYTHON_STRICT_BYTE_CHAR
%}
%
nodefaultctor
;
%
nodefaultctor
;
...
@@ -83,11 +86,11 @@
...
@@ -83,11 +86,11 @@
PyErr_SetString(PyExc_ValueError, "Expecting a string");
PyErr_SetString(PyExc_ValueError, "Expecting a string");
return NULL;
return NULL;
} else {
} else {
$1 = *(uint8_t*)Py
String
_AsString($input);
$1 = *(uint8_t*)Py
Bytes
_AsString($input);
}
}
}
}
%
typemap
(
out
)
HBytes
*
{
%
typemap
(
out
)
HBytes
*
{
$result = Py
String
_FromStringAndSize((char*)$1->token, $1->len);
$result = Py
Bytes
_FromStringAndSize((char*)$1->token, $1->len);
}
}
%
typemap
(
out
)
struct
HCountedArray_
*
{
%
typemap
(
out
)
struct
HCountedArray_
*
{
int i;
int i;
...
@@ -187,7 +190,7 @@
...
@@ -187,7 +190,7 @@
return PyObject_CallFunctionObjArgs(_helper_Placeholder, NULL);
return PyObject_CallFunctionObjArgs(_helper_Placeholder, NULL);
break;
break;
case TT_BYTES:
case TT_BYTES:
return Py
String
_FromStringAndSize((char*)token->token_data.bytes.token, token->token_data.bytes.len);
return Py
Bytes
_FromStringAndSize((char*)token->token_data.bytes.token, token->token_data.bytes.len);
case TT_SINT:
case TT_SINT:
// TODO: return PyINT if appropriate
// TODO: return PyINT if appropriate
return PyLong_FromLong(token->token_data.sint);
return PyLong_FromLong(token->token_data.sint);
...
...
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