Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

sobj_addr.c File Reference


Detailed Description

Address resolution helper functions.

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "sobject_p.h"

Include dependency graph for sobj_addr.c:

Include dependency graph

Functions

sobjsobj_addr_x_append (struct sobj *, struct sobj *, bool, struct sobj_env *)
 Perform an append operation on an object.
sobjsobj_addr_x_index (struct sobj *, struct sobj *, int, bool, struct sobj_env *)
 Perform a set index operation on an object.
void sobj_addr_slice_bounds (int *, int *, int)
 Compute the effective lower and upper bounds.
sobjsobj_addr_x_slice (struct sobj *, struct sobj *, int, int, bool, struct sobj_env *)
 Perform a set slice operation on an object.
sobjsobj_addr_set_index (struct sobj *, struct sobj *, struct sobj *, struct sobj *, bool, struct sobj_env *)
 Set operation helper for index addresses.
sobjsobj_addr_set_select (struct sobj *, struct sobj *, struct sobj *, struct sobj *, struct sobj_env *)
 Set operation helper for selection addresses.
sobjsobj_addr_get_index (struct sobj *, struct sobj *, struct sobj_array *, bool, struct sobj_env *)
 Helper for the get method (index).
sobjsobj_addr_get_slice (struct sobj *, struct sobj *, struct sobj_array *, struct sobj_env *)
 Helper for the get method (slice).
sobjsobj_addr_get_select (struct sobj *, struct sobj *, struct sobj *, bool, struct sobj_env *)
 Helper for the get method (selection).
sobjsobj_addr_set (struct sobj *self, struct sobj *address, struct sobj *value, bool slice, struct sobj_env *env)
 Internal function performing a set operation.
sobjsobj_addr_get (struct sobj *self, struct sobj *address, bool pure, struct sobj_env *env)
 Internal function performing a get operation.
sobjsobj_address (const char *address, struct sobj_env *env)
 Convert an address string to an address object.
void sobj_address_string (struct sobj *address, struct sobj_buffer *buffer, struct sobj_env *env)
 Convert an address object to an address string.

Function Documentation

struct sobj* sobj_addr_get struct sobj self,
struct sobj address,
bool  pure,
struct sobj_env env
 

Internal function performing a get operation.

Parameters:
self The object the get method was called on.
address The address of the get operation.
pure Flag indicating if a pure address resolution should be performed. If this flag is set, the object returned is either a propper subjobject of the called object or a null-pointer. The pure flag has the following effects:
  • Slice indices are not resolved (i.e. a null-pointer is returned).
  • Quoted addresses (unary plus) are not resolved.
  • No expression objects are created when a key or index is not found or out of bounds.
  • No self selection is performed, i.e. a null-pointer is returned if the address can't be resolved. (Self selection: In a non-pure get operation, the selected object may be the address itself if no other resolution rule matches.)
env The environment. This may be a null-pointer.
Returns:
The function returns the selected object. If the pure flag is set, this may be a null-pointer. Note that the function will never return a null-pointer if the pure flag is clear.

struct sobj * sobj_addr_get_index struct sobj self,
struct sobj address,
struct sobj_array index_array,
bool  pure,
struct sobj_env env
[static]
 

Helper for the get method (index).

This function is called by sobj_addr_get() to resolve index addresses (i.e. index expressions where the index array contains a single element).

Parameters:
self The object the get method was called on.
address The left operand of the index address.
index_array The right array operand of the index address. This has to be a 1 element array.
pure The pure flag as passed to sobj_addr_get().
env The environment. This may be a null-pointer.
Returns:
Return the result of the index operation. If the operand is not an array and pure is clear, an index expression is created and returned. Note that the function will never return null if pure is clear.

struct sobj * sobj_addr_get_select struct sobj self,
struct sobj address,
struct sobj selector,
bool  pure,
struct sobj_env env
[static]
 

Helper for the get method (selection).

This function is called by sobj_addr_get() to resolve selection addresses.

Parameters:
self The object the get method was called on.
address The left operand of the selection address.
selector The right operand of the selector address.
pure The pure flag as passed to sobj_addr_get().
env The environment object.
Returns:
Return the result of the selection operation. If the selected object is not found or the operand is not an array and if pure is clear, a selection expression is created and returned. Note that the function will never return null if pure is clear.

struct sobj * sobj_addr_get_slice struct sobj self,
struct sobj address,
struct sobj_array index_array,
struct sobj_env env
[static]
 

Helper for the get method (slice).

This function is called by sobj_addr_get() to resolve slice addresses (i.e. index expressions where the index array contains exactly two elements).

Parameters:
self The object the get method was called on.
address The left operand of the index address.
index_array The right array operand of the index address. This has to be a 2 element array.
env The environment. This may be a null-pointer.
Returns:
Return the result of the slice operation. If operand is not an array and pure is clear, an index expression is created and returned. Note that the function will never return null if pure is clear.

struct sobj* sobj_addr_set struct sobj self,
struct sobj address,
struct sobj value,
bool  slice,
struct sobj_env env
 

Internal function performing a set operation.

Parameters:
self The object the set method was called on.
address The address of the set operation.
value The value to be substituted in place of the addressed subjobject.
slice Flag indicating sliced operation. The specified value is interpreted as a slice.
env The environment. This may be a null-pointer.
Returns:
The function returns the modified object on success and a null-pointer on failure.

struct sobj * sobj_addr_set_index struct sobj self,
struct sobj address,
struct sobj selector,
struct sobj value,
bool  slice,
struct sobj_env env
[static]
 

Set operation helper for index addresses.

This is a helper function called by sobj_addr_set() if the address expression type is index.

Parameters:
self The object the set method was called on.
address The address of the index operation (left operand of the address index expression).
selector The right operand of the address index expression. This is interpreted as an address and resolved using get operation.
value The value to be substituted in place of the addressed subjobject.
slice Flag indicating if the specified value should be interpreted as a single object or as an array slice. If this flag is set, the parameter value has to be of type array and is interpreted as a slice.
env The environment. This may be a null-pointer.
Returns:
The function returns the modified object on success and a null-pointer on failure.

struct sobj * sobj_addr_set_select struct sobj self,
struct sobj address,
struct sobj selector,
struct sobj value,
struct sobj_env env
[static]
 

Set operation helper for selection addresses.

This is a helper function called by sobj_addr_set() if the address expression type is select.

Parameters:
self The object the set method was called on.
address The address of the selection operation (left operand of the address select expression).
selector The right operand of the address select expression. This is interpreted as an address and resolved using get operation.
value The value to be substituted in place of the addressed subjobject.
env The environment. This may be a null-pointer.
Returns:
The function returns the modified object on success and a null-pointer on failure.

void sobj_addr_slice_bounds int *  lower_bound_ref,
int *  upper_bound_ref,
int  n
[static]
 

Compute the effective lower and upper bounds.

The function takes a length of a sequence and a pair of lower and upper bounds. The effective lower and upper bounds are computed.

Parameters:
lower_bound_ref Pointer to a variable holding the specified lower bound. The effective lower bound will be written to *lower_bound_ref.
upper_bound_ref Pointer to a variable holding the specified upper bound. The effective upper bound will be written to *upper_bound_ref.
n The length of the sequence.

struct sobj * sobj_addr_x_append struct sobj x,
struct sobj value,
bool  slice,
struct sobj_env env
[static]
 

Perform an append operation on an object.

Parameters:
x The object the append operation is performed on. A null-pointer indicates that the object does not exist an should be created. A null-pointer is interpreted as an empty array. The operation depends on the type of x:
  • x is null or an array:
    The operation is an append operation on an array. The result will be an array object.
  • x is a string:
    The operation is an append operation on a string. The result will be the concatenation of the strings x and value. The operation will fail if value is not a string.
value The value object that is to be appended to the specified object.
slice Flag indicating if the operation appends the object as an object or as a slice.
  • slice == true
    If x is null or an array, value is expected to be an array (otherwise the append operation will fail) and the result is the concatenation of x and value (where null is interpreted as an empty array).
  • slice == false
    If x is null or an array, value is append to the array x, associated with the key NIL (where null is interpreted as an empty array).
env The environment. This may be a null-pointer.
Returns:
The function returns the resulting array or string object. If the append operation failed, a null-pointer is returned.

struct sobj * sobj_addr_x_index struct sobj x,
struct sobj value,
int  index,
bool  slice,
struct sobj_env env
[static]
 

Perform a set index operation on an object.

Parameters:
x The object the set index operation should be performed on. A null-pointer indicates that the object does not exist and must be created. If x is not null, is has to be either a string or an array, otherwise the operation will fail. If x is null, it is interpreted as an empty array. The operation depends on the type of x:
  • x is null or an array:
    The operation will result in a modified array.
  • x is a string:
    The operation will result in a modified string.
value The value object that is to be set.
index The specified array or string index. If the index is negative, it is counted from the end of the array or string. If the index points to the end of the array or string (i.e. the position following the last element position), the specified value is appended to the array or string. If the index is out of bounds, the operation will fail.
slice Flag indicating if the operation replaces an object with an object or a slice.
  • slice == true
    If x is null or an array, value is expected to be an array (otherwise the append operation will fail) and the result is the array x with the element at position index replaced with the elements from value (null is interpreted as an empty array).
  • slice == false
    If x is null or an array, value will replace the object at position index (where null is interpreted as an empty array). The key of that element will remain unchanged.
env The environment. This may be a null-pointer.
Returns:
The function returns the resulting array or string object. If the set operation fails, a null-pointer is returned.

struct sobj * sobj_addr_x_slice struct sobj x,
struct sobj value,
int  lower_bound,
int  upper_bound,
bool  slice,
struct sobj_env env
[static]
 

Perform a set slice operation on an object.

Parameters:
x The object the set slice operation should be performed on. A null-pointer indicates that the object does not exist and must be created. If x is not null, is has to be either a string or an array, otherwise the operation will fail. If x is null, it is interpreted as an empty array. The operation depends on the type of x:
  • x is null or an array:
    The operation will result in a modified array.
  • x is a string:
    The operation will result in a modified string.
value The value object that is to be set.
lower_bound The specified lower bound of the array or string slice. The effective lower bound will be computed from the specified value.
upper_bound The specified upper bound of the array or string slice. The effective upper bound will be computed from the specified value.
slice Flag indicating if the operation replaces the specified slice with an object or a slice.
  • slice == true
    If x is null or an array, value is expected to be an array (otherwise the append operation will fail) and the result is the array x with the elements in the slice [lower_boundupper_bound] replaced with the elements from value (null is interpreted as an empty array).
  • slice == false
    If x is null or an array, value will replace the elements in the slice [lower_boundupper_bound] (where null is interpreted as an empty array). The key of the new element will be NIL.
env The environment. This may be a null-pointer.
Returns:
The function returns the resulting array or string object. If the set operation fails, a null-pointer is returned.


Generated on Sat Jul 23 16:04:45 2005 for sobject by  doxygen 1.3.9.1