Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
binary_c-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Izzard, Robert Dr (Maths & Physics)
binary_c-python
Commits
5cfc1e5d
Commit
5cfc1e5d
authored
5 years ago
by
David Hendriks
Browse files
Options
Downloads
Patches
Plain Diff
Synched with master
parent
f2793646
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.binary_c_python_api.c.swp
+0
-0
0 additions, 0 deletions
.binary_c_python_api.c.swp
binary_c_python.c
+51
-11
51 additions, 11 deletions
binary_c_python.c
binary_c_python.h
+6
-4
6 additions, 4 deletions
binary_c_python.h
binary_c_python_api.c
+21
-23
21 additions, 23 deletions
binary_c_python_api.c
with
78 additions
and
38 deletions
.binary_c_python_api.c.swp
deleted
100644 → 0
+
0
−
0
View file @
f2793646
File deleted
This diff is collapsed.
Click to expand it.
binary_c_python.c
+
51
−
11
View file @
5cfc1e5d
...
...
@@ -156,6 +156,9 @@ static PyObject* binary_c_new_binary_system(PyObject *self, PyObject *args)
static
PyObject
*
binary_c_function_prototype
(
PyObject
*
self
,
PyObject
*
args
)
{
// This function is an very bare example of how a function would look like.
double
var1
,
var2
;
/* Parse the input tuple */
...
...
@@ -224,27 +227,64 @@ static PyObject* binary_c_run_binary_with_log(PyObject *self, PyObject *args)
else
{
char
*
buffer
;
int
nbytes
;
char
*
error_buffer
;
size_t
nbytes
;
int
out
MAYBE_UNUSED
=
run_binary_with_log
(
argstring
,
&
buffer
,
&
error_buffer
,
&
nbytes
);
/* copy the buffer to a python string */
PyObject
*
ret
=
Py_BuildValue
(
"s"
,
buffer
);
free
(
buffer
);
return
ret
;
PyObject
*
return_string
=
Py_BuildValue
(
"s"
,
buffer
);
PyObject
*
return_error_string
MAYBE_UNUSED
=
Py_BuildValue
(
"s"
,
error_buffer
);
if
(
error_buffer
!=
NULL
&&
strlen
(
error_buffer
)
>
0
)
{
fprintf
(
stderr
,
"Error in binary_c run : %s
\n
"
,
error_buffer
);
}
Safe_free
(
buffer
);
Safe_free
(
error_buffer
);
/*
* TODO
* return the return_error_string as well!
*/
return
return_string
;
}
}
static
PyObject
*
binary_c_return_arglines
(
PyObject
*
self
,
PyObject
*
args
)
{
/* Binary structures */
char
*
buffer
;
int
nbytes
;
char
*
error_buffer
;
size_t
nbytes
;
int
out
MAYBE_UNUSED
=
return_arglines
(
&
buffer
,
&
nbytes
);
&
error_buffer
,
&
nbytes
);
/* copy the buffer to a python string */
PyObject
*
ret
=
Py_BuildValue
(
"s"
,
buffer
);
free
(
buffer
);
/* Return an object containing the arg list */
return
ret
;
PyObject
*
return_string
=
Py_BuildValue
(
"s"
,
buffer
);
PyObject
*
return_error_string
MAYBE_UNUSED
=
Py_BuildValue
(
"s"
,
error_buffer
);
if
(
error_buffer
!=
NULL
&&
strlen
(
error_buffer
)
>
0
)
{
fprintf
(
stderr
,
"Error in binary_c run : %s
\n
"
,
error_buffer
);
}
Safe_free
(
buffer
);
Safe_free
(
error_buffer
);
/*
* TODO
* return the return_error_string as well!
*/
return
return_string
;
}
This diff is collapsed.
Click to expand it.
binary_c_python.h
+
6
−
4
View file @
5cfc1e5d
...
...
@@ -15,11 +15,13 @@ int run_binary (char * argstring,
size_t
*
const
nbytes
);
int
run_binary_with_log
(
char
*
argstring
,
char
**
outstring
,
int
*
nbytes
);
char
**
const
outstring
,
char
**
const
errorstring
,
size_t
*
const
nbytes
);
int
return_arglines
(
char
**
buffer
,
int
*
nbytes
);
int
return_arglines
(
char
**
const
outstring
,
char
**
const
errorstring
,
size_t
*
const
nbytes
);
/* C macros */
#define BINARY_C_APITEST_VERSION 0.1
...
...
This diff is collapsed.
Click to expand it.
binary_c_python_api.c
+
21
−
23
View file @
5cfc1e5d
...
...
@@ -94,7 +94,6 @@ int run_binary(char * argstring,
&
store
,
&
argstring
,
-
1
);
printf
(
"have new stardata %p
\n
"
,
stardata
);
fflush
(
NULL
);
/* disable logging */
snprintf
(
stardata
->
preferences
->
log_filename
,
...
...
@@ -129,8 +128,9 @@ int run_binary(char * argstring,
return
0
;
}
int
return_arglines
(
char
**
buffer
,
int
*
nbytes
)
int
return_arglines
(
char
**
const
buffer
,
char
**
const
error_buffer
,
size_t
*
const
nbytes
)
{
/* memory for N binary systems */
struct
libbinary_c_stardata_t
*
stardata
;
...
...
@@ -157,8 +157,7 @@ int return_arglines(char ** buffer,
"/dev/null"
);
/* output to strings */
stardata
->
preferences
->
internal_buffering
=
2
;
stardata
->
preferences
->
internal_buffering_compression
=
0
;
stardata
->
preferences
->
internal_buffering
=
INTERNAL_BUFFERING_STORE
;
stardata
->
preferences
->
batchmode
=
BATCHMODE_LIBRARY
;
/* List available arguments */
...
...
@@ -166,19 +165,24 @@ int return_arglines(char ** buffer,
/* get buffer pointer */
binary_c_buffer_info
(
stardata
,
buffer
,
nbytes
);
/* get error buffer pointer */
binary_c_error_buffer
(
stardata
,
error_buffer
);
/* set raw_buffer_size = -1 to prevent it being freed */
stardata
->
tmpstore
->
raw_buffer_size
=
-
1
;
/* free stardata (except the buffer) */
binary_c_free_memory
(
&
stardata
,
TRUE
,
TRUE
,
FALSE
);
binary_c_free_memory
(
&
stardata
,
TRUE
,
TRUE
,
FALSE
,
FALSE
);
binary_c_free_store_contents
(
store
);
return
0
;
}
int
run_binary_with_log
(
char
*
argstring
,
char
**
buffer
,
int
*
nbytes
)
char
**
const
buffer
,
char
**
const
error_buffer
,
size_t
*
const
nbytes
)
{
/* memory for N binary systems */
struct
libbinary_c_stardata_t
*
stardata
;
...
...
@@ -192,32 +196,26 @@ int run_binary_with_log(char * argstring,
&
store
,
&
argstring
,
-
1
);
/* disable logging */
// snprintf(stardata->preferences->log_filename,
// STRING_LENGTH-1,
// "%s",
// "/dev/null");
// snprintf(stardata->preferences->api_log_filename_prefix,
// STRING_LENGTH-1,
// "%s",
// "/dev/null");
/* output to strings */
stardata
->
preferences
->
internal_buffering
=
2
;
stardata
->
preferences
->
internal_buffering_compression
=
0
;
stardata
->
preferences
->
internal_buffering
=
INTERNAL_BUFFERING_STORE
;
stardata
->
preferences
->
batchmode
=
BATCHMODE_LIBRARY
;
/* do binary evolution */
binary_c_evolve_for_dt
(
stardata
,
stardata
->
model
.
max_evolution_time
);
/* get buffer pointer */
binary_c_buffer_info
(
stardata
,
buffer
,
nbytes
);
/* get error buffer pointer */
binary_c_error_buffer
(
stardata
,
error_buffer
);
/* set raw_buffer_size = -1 to prevent it being freed */
stardata
->
tmpstore
->
raw_buffer_size
=
-
1
;
/* free stardata (except the buffer) */
binary_c_free_memory
(
&
stardata
,
TRUE
,
TRUE
,
FALSE
);
binary_c_free_memory
(
&
stardata
,
TRUE
,
TRUE
,
FALSE
,
FALSE
);
binary_c_free_store_contents
(
store
);
return
0
;
}
...
...
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