Python frame structure and related algorithms.
More...
#include "../report_type.h"
#include <json.h>
#include <stdbool.h>
#include <stdint.h>
#include <glib.h>
Go to the source code of this file.
Python frame structure and related algorithms.
Definition in file python/frame.h.
◆ sr_python_frame_append()
Appends 'item' at the end of the list 'dest'.
- Returns
- This function returns the 'dest' frame. If 'dest' is NULL, it returns the 'item' frame.
◆ sr_python_frame_append_to_str()
void sr_python_frame_append_to_str |
( |
struct sr_python_frame * |
frame, |
|
|
GString * |
dest |
|
) |
| |
Appends textual representation of the frame to the string buffer dest.
◆ sr_python_frame_cmp()
Compares two python frames.
- Parameters
-
frame1 | It must be non-NULL pointer. It's not modified by calling this function. |
frame2 | It must be non-NULL pointer. It's not modified by calling this function. |
- Returns
- Returns 0 if the frames are same. Returns negative number if frame1 is found to be 'less' than frame2. Returns positive number if frame1 is found to be 'greater' than frame2.
◆ sr_python_frame_cmp_distance()
Compares two python frames.
- Parameters
-
frame1 | It must be non-NULL pointer. It's not modified by calling this function. |
frame2 | It must be non-NULL pointer. It's not modified by calling this function. |
- Returns
- Returns 0 if the frames are same. Returns negative number if frame1 is found to be 'less' than frame2. Returns positive number if frame1 is found to be 'greater' than frame2.
◆ sr_python_frame_dup()
Creates a duplicate of the frame.
- Parameters
-
frame | It must be non-NULL pointer. The frame is not modified by calling this function. |
siblings | Whether to duplicate also siblings referenced by frame->next. If false, frame->next is not duplicated for the new frame, but it is set to NULL. |
- Returns
- This function never returns NULL. The returned duplicate frame must be released by calling the function sr_python_frame_free().
◆ sr_python_frame_free()
Releases the memory held by the frame. The frame siblings are not released.
- Parameters
-
frame | If the frame is NULL, no operation is performed. |
◆ sr_python_frame_from_json()
struct sr_python_frame * sr_python_frame_from_json |
( |
json_object * |
root, |
|
|
char ** |
error_message |
|
) |
| |
Deserializes frame structure from JSON representation.
- Parameters
-
root | JSON value to be deserialized. |
error_message | On error, *error_message will contain the description of the error. |
- Returns
- Resulting frame, or NULL on error.
◆ sr_python_frame_init()
Initializes all members of the frame structure to their default values. No memory is released, members are simply overwritten. This is useful for initializing a frame structure placed on the stack.
◆ sr_python_frame_new()
Creates and initializes a new frame structure.
- Returns
- It never returns NULL. The returned pointer must be released by calling the function sr_python_frame_free().
◆ sr_python_frame_parse()
If the input contains a complete frame, this function parses the frame text, returns it in a structure, and moves the input pointer after the frame. If the input does not contain proper, complete frame, the function does not modify input and returns NULL.
- Returns
- Allocated pointer with a frame structure. The pointer should be released by sr_python_frame_free().
- Parameters
-
location | The caller must provide a pointer to an instance of sr_location here. When this function returns NULL, the structure will contain the error line, column, and message. The line and column members of the location are gradually increased as the parser handles the input, so the location should be initialized before calling this function to get reasonable values. |
◆ sr_python_frame_to_json()
Returns a textual representation of the frame.
- Parameters
-
frame | It must be a non-NULL pointer. It's not modified by calling this function. |