2012-12-16 04:48:36 +00:00
|
|
|
/*
|
|
|
|
rua_set.c
|
|
|
|
|
|
|
|
Ruamoko set api
|
|
|
|
|
|
|
|
Copyright (C) 2012 Bill Currie
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2012/12/15
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "QF/progs.h"
|
|
|
|
#include "QF/set.h"
|
|
|
|
|
2022-01-08 15:26:52 +00:00
|
|
|
#include "QF/progs/pr_obj.h"
|
|
|
|
|
2012-12-16 04:48:36 +00:00
|
|
|
#include "rua_internal.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
pr_id_t obj;
|
|
|
|
pr_int_t set;
|
|
|
|
} pr_set_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
pr_id_t obj;
|
2021-12-23 10:43:27 +00:00
|
|
|
pr_int_t set;
|
2012-12-16 04:48:36 +00:00
|
|
|
pr_int_t iter;
|
|
|
|
} pr_set_iter_t;
|
|
|
|
|
|
|
|
typedef struct bi_set_s {
|
|
|
|
struct bi_set_s *next;
|
|
|
|
struct bi_set_s **prev;
|
|
|
|
set_t *set;
|
|
|
|
} bi_set_t;
|
|
|
|
|
|
|
|
typedef struct bi_set_iter_s {
|
|
|
|
struct bi_set_iter_s *next;
|
|
|
|
struct bi_set_iter_s **prev;
|
|
|
|
set_iter_t *iter;
|
|
|
|
} bi_set_iter_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PR_RESMAP (bi_set_t) set_map;
|
|
|
|
PR_RESMAP (bi_set_iter_t) set_iter_map;
|
|
|
|
bi_set_t *sets;
|
|
|
|
bi_set_iter_t *set_iters;
|
|
|
|
} set_resources_t;
|
|
|
|
|
|
|
|
static bi_set_t *
|
|
|
|
res_set_new (set_resources_t *res)
|
|
|
|
{
|
2021-03-21 12:26:36 +00:00
|
|
|
return PR_RESNEW (res->set_map);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
res_set_free (set_resources_t *res, bi_set_t *set)
|
|
|
|
{
|
2021-03-21 12:26:36 +00:00
|
|
|
PR_RESFREE (res->set_map, set);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
res_set_reset (set_resources_t *res)
|
|
|
|
{
|
2021-03-21 12:26:36 +00:00
|
|
|
PR_RESRESET (res->set_map);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bi_set_t *
|
|
|
|
res_set_get (set_resources_t *res, int index)
|
|
|
|
{
|
2021-03-21 12:26:36 +00:00
|
|
|
return PR_RESGET(res->set_map, index);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
2020-12-20 17:12:51 +00:00
|
|
|
static inline int __attribute__((pure))
|
2012-12-16 04:48:36 +00:00
|
|
|
res_set_index (set_resources_t *res, bi_set_t *set)
|
|
|
|
{
|
2021-03-21 12:26:36 +00:00
|
|
|
return PR_RESINDEX(res->set_map, set);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bi_set_iter_t *
|
|
|
|
res_set_iter_new (set_resources_t *res)
|
|
|
|
{
|
2021-03-21 12:26:36 +00:00
|
|
|
return PR_RESNEW (res->set_iter_map);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
res_set_iter_free (set_resources_t *res, bi_set_iter_t *set_iter)
|
|
|
|
{
|
2021-03-21 12:26:36 +00:00
|
|
|
PR_RESFREE (res->set_iter_map, set_iter);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
res_set_iter_reset (set_resources_t *res)
|
|
|
|
{
|
2021-03-21 12:26:36 +00:00
|
|
|
PR_RESRESET (res->set_iter_map);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bi_set_iter_t *
|
|
|
|
res_set_iter_get (set_resources_t *res, int index)
|
|
|
|
{
|
2021-03-21 12:26:36 +00:00
|
|
|
return PR_RESGET(res->set_iter_map, index);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
2020-12-20 17:12:51 +00:00
|
|
|
static inline int __attribute__((pure))
|
2012-12-16 04:48:36 +00:00
|
|
|
res_set_iter_index (set_resources_t *res, bi_set_iter_t *set_iter)
|
|
|
|
{
|
2021-03-21 12:26:36 +00:00
|
|
|
return PR_RESINDEX(res->set_iter_map, set_iter);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
2022-02-14 10:30:50 +00:00
|
|
|
static bi_set_t * __attribute__((pure))
|
2022-02-14 03:28:38 +00:00
|
|
|
get_set (progs_t *pr, set_resources_t *res, const char *name, int index)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
|
|
|
bi_set_t *set = res_set_get (res, index);
|
|
|
|
|
|
|
|
if (!set)
|
|
|
|
PR_RunError (pr, "invalid set index passed to %s", name + 3);
|
|
|
|
return set;
|
|
|
|
}
|
|
|
|
|
2022-02-14 10:30:50 +00:00
|
|
|
static bi_set_iter_t * __attribute__((pure))
|
2022-02-14 03:28:38 +00:00
|
|
|
get_set_iter (progs_t *pr, set_resources_t *res, const char *name, int index)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
|
|
|
bi_set_iter_t *set = res_set_iter_get (res, index);
|
|
|
|
|
|
|
|
if (!set)
|
|
|
|
PR_RunError (pr, "invalid set iterator index passed to %s", name + 3);
|
|
|
|
return set;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
del_set_iter (progs_t *pr, set_resources_t *res, bi_set_iter_t *set_iter)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
|
|
|
*set_iter->prev = set_iter->next;
|
|
|
|
if (set_iter->next)
|
|
|
|
set_iter->next->prev = set_iter->prev;
|
|
|
|
res_set_iter_free (res, set_iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_del_iter (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
bi_set_iter_t *set_iter = get_set_iter (pr, res, __FUNCTION__,
|
|
|
|
P_INT (pr, 0));
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
set_del_iter (set_iter->iter);
|
2022-02-14 03:28:38 +00:00
|
|
|
del_set_iter (pr, res, set_iter);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
2022-01-23 12:54:03 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_iter_element (progs_t *pr, void *_res)
|
2022-01-23 12:54:03 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
bi_set_iter_t *set_iter = get_set_iter (pr, res, __FUNCTION__,
|
|
|
|
P_INT (pr, 0));
|
2022-01-23 12:54:03 +00:00
|
|
|
|
|
|
|
R_INT (pr) = set_iter->iter->element;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-12-16 04:48:36 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_new (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2012-12-16 04:48:36 +00:00
|
|
|
bi_set_t *set;
|
|
|
|
|
|
|
|
set = res_set_new (res);
|
|
|
|
|
|
|
|
set->next = res->sets;
|
|
|
|
set->prev = &res->sets;
|
|
|
|
if (res->sets)
|
|
|
|
res->sets->prev = &set->next;
|
|
|
|
res->sets = set;
|
|
|
|
|
|
|
|
set->set = set_new ();
|
|
|
|
|
|
|
|
R_INT (pr) = res_set_index (res, set);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_delete (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, P_INT (pr, 0));
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
set_delete (set->set);
|
|
|
|
*set->prev = set->next;
|
|
|
|
if (set->next)
|
|
|
|
set->next->prev = set->prev;
|
|
|
|
res_set_free (res, set);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_add (progs_t *pr, set_resources_t *res,
|
|
|
|
pr_int_t setid, pr_uint_t element)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, setid);
|
2022-02-04 13:19:05 +00:00
|
|
|
|
|
|
|
set_add (set->set, element);
|
|
|
|
}
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-04 13:19:05 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_add (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_add (pr, res, P_INT (pr, 0), P_UINT (pr, 1));
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = P_INT (pr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_remove (progs_t *pr, set_resources_t *res,
|
|
|
|
pr_int_t setid, pr_uint_t element)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, setid);
|
2022-02-04 13:19:05 +00:00
|
|
|
|
|
|
|
set_remove (set->set, element);
|
|
|
|
}
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-04 13:19:05 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_remove (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_remove (pr, res, P_INT (pr, 0), P_UINT (pr, 1));
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = P_INT (pr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_invert (progs_t *pr, set_resources_t *res, pr_int_t setid)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, setid);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
set_invert (set->set);
|
2022-02-04 13:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_invert (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_invert (pr, res, P_INT (pr, 0));
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = P_INT (pr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_union (progs_t *pr, set_resources_t *res,
|
|
|
|
pr_int_t dstid, pr_int_t srcid)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *dst = get_set (pr, res, __FUNCTION__, dstid);
|
|
|
|
bi_set_t *src = get_set (pr, res, __FUNCTION__, srcid);
|
2022-02-04 13:19:05 +00:00
|
|
|
|
|
|
|
set_union (dst->set, src->set);
|
|
|
|
}
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-04 13:19:05 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_union (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_union (pr, res, P_INT (pr, 0), P_INT (pr, 1));
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = P_INT (pr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_intersection (progs_t *pr, set_resources_t *res,
|
|
|
|
pr_int_t dstid, pr_int_t srcid)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *dst = get_set (pr, res, __FUNCTION__, dstid);
|
|
|
|
bi_set_t *src = get_set (pr, res, __FUNCTION__, srcid);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-04 13:19:05 +00:00
|
|
|
set_intersection (dst->set, src->set);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_intersection (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_intersection (pr, res, P_INT (pr, 0), P_INT (pr, 1));
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = P_INT (pr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_difference (progs_t *pr, set_resources_t *res,
|
|
|
|
pr_int_t dstid, pr_int_t srcid)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *dst = get_set (pr, res, __FUNCTION__, dstid);
|
|
|
|
bi_set_t *src = get_set (pr, res, __FUNCTION__, srcid);
|
2022-02-04 13:19:05 +00:00
|
|
|
|
|
|
|
set_difference (dst->set, src->set);
|
|
|
|
}
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-04 13:19:05 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_difference (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_difference (pr, res, P_INT (pr, 0), P_INT (pr, 1));
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = P_INT (pr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_reverse_difference (progs_t *pr, set_resources_t *res,
|
|
|
|
pr_int_t dstid, pr_int_t srcid)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *dst = get_set (pr, res, __FUNCTION__, dstid);
|
|
|
|
bi_set_t *src = get_set (pr, res, __FUNCTION__, srcid);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-04 13:19:05 +00:00
|
|
|
set_reverse_difference (dst->set, src->set);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_reverse_difference (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_reverse_difference (pr, res, P_INT (pr, 0), P_INT (pr, 1));
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = P_INT (pr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_assign (progs_t *pr, set_resources_t *res,
|
|
|
|
pr_int_t dstid, pr_int_t srcid)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *dst = get_set (pr, res, __FUNCTION__, dstid);
|
|
|
|
bi_set_t *src = get_set (pr, res, __FUNCTION__, srcid);
|
2022-02-04 13:19:05 +00:00
|
|
|
|
|
|
|
set_assign (dst->set, src->set);
|
|
|
|
}
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-04 13:19:05 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_assign (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_assign (pr, res, P_INT (pr, 0), P_INT (pr, 1));
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = P_INT (pr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_empty (progs_t *pr, set_resources_t *res, pr_int_t setid)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, setid);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
set_empty (set->set);
|
2022-02-04 13:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_empty (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_empty (pr, res, P_INT (pr, 0));
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = P_INT (pr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_everything (progs_t *pr, set_resources_t *res, pr_int_t setid)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, setid);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
set_everything (set->set);
|
2022-02-04 13:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_everything (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_everything (pr, res, P_INT (pr, 0));
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = P_INT (pr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_empty (progs_t *pr, set_resources_t *res, pr_int_t setid)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, setid);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
R_INT (pr) = set_is_empty (set->set);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_is_empty (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_is_empty (pr, res, P_INT (pr, 0));
|
2022-02-04 13:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_everything (progs_t *pr, set_resources_t *res, pr_int_t setid)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, P_INT (pr, 0));
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
R_INT (pr) = set_is_everything (set->set);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_is_everything (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_is_everything (pr, res, P_INT (pr, 0));
|
2022-02-04 13:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_disjoint (progs_t *pr, set_resources_t *res,
|
|
|
|
pr_int_t sid1, pr_int_t sid2)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set1 = get_set (pr, res, __FUNCTION__, sid1);
|
|
|
|
bi_set_t *set2 = get_set (pr, res, __FUNCTION__, sid2);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
R_INT (pr) = set_is_disjoint (set1->set, set2->set);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_is_disjoint (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_is_disjoint (pr, res, P_INT (pr, 0), P_INT (pr, 1));
|
2022-02-04 13:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_intersecting (progs_t *pr, set_resources_t *res,
|
|
|
|
pr_int_t sid1, pr_int_t sid2)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set1 = get_set (pr, res, __FUNCTION__, sid1);
|
|
|
|
bi_set_t *set2 = get_set (pr, res, __FUNCTION__, sid2);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
R_INT (pr) = set_is_intersecting (set1->set, set2->set);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_is_intersecting (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_is_intersecting (pr, res, P_INT (pr, 0), P_INT (pr, 1));
|
2022-02-04 13:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_equivalent (progs_t *pr, set_resources_t *res,
|
|
|
|
pr_int_t sid1, pr_int_t sid2)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set1 = get_set (pr, res, __FUNCTION__, sid1);
|
|
|
|
bi_set_t *set2 = get_set (pr, res, __FUNCTION__, sid2);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
R_INT (pr) = set_is_equivalent (set1->set, set2->set);
|
|
|
|
}
|
|
|
|
|
2022-02-04 13:19:05 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_is_equivalent (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_is_equivalent (pr, res, P_INT (pr, 0), P_INT (pr, 1));
|
2022-02-04 13:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_subset (progs_t *pr, set_resources_t *res, pr_int_t setid,
|
|
|
|
pr_int_t subid)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, setid);
|
|
|
|
bi_set_t *sub = get_set (pr, res, __FUNCTION__, subid);
|
2022-02-04 13:19:05 +00:00
|
|
|
|
|
|
|
R_INT (pr) = set_is_subset (set->set, sub->set);
|
|
|
|
}
|
|
|
|
|
2012-12-16 04:48:36 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_is_subset (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_is_subset (pr, res, P_INT (pr, 0), P_INT (pr, 1));
|
2022-02-04 13:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_member (progs_t *pr, set_resources_t *res, pr_int_t setid,
|
|
|
|
pr_uint_t element)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, setid);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-04 13:19:05 +00:00
|
|
|
R_INT (pr) = set_is_member (set->set, element);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_is_member (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_is_member (pr, res, P_INT (pr, 0), P_UINT (pr, 1));
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_count (progs_t *pr, set_resources_t *res, pr_int_t setid)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, setid);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2021-07-27 02:52:21 +00:00
|
|
|
R_INT (pr) = set_count (set->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
2022-02-04 13:19:05 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_count (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_count (pr, res, P_INT (pr, 0));
|
2022-02-04 13:19:05 +00:00
|
|
|
}
|
|
|
|
|
2012-12-16 04:48:36 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_first (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, P_INT (pr, 0));
|
2012-12-16 04:48:36 +00:00
|
|
|
set_iter_t *iter;
|
|
|
|
bi_set_iter_t *set_iter;
|
|
|
|
|
|
|
|
iter = set_first (set->set);
|
|
|
|
if (!iter) {
|
|
|
|
R_INT (pr) = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
set_iter = res_set_iter_new (res);
|
|
|
|
|
|
|
|
set_iter->next = res->set_iters;
|
|
|
|
set_iter->prev = &res->set_iters;
|
|
|
|
if (res->set_iters)
|
|
|
|
res->set_iters->prev = &set_iter->next;
|
|
|
|
res->set_iters = set_iter;
|
|
|
|
|
2021-01-09 11:42:23 +00:00
|
|
|
set_iter->iter = iter;
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
R_INT (pr) = res_set_iter_index (res, set_iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_next (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
bi_set_iter_t *set_iter = get_set_iter (pr, res, __FUNCTION__,
|
|
|
|
P_INT (pr, 0));
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
if (!set_next (set_iter->iter)) {
|
2022-02-14 03:28:38 +00:00
|
|
|
del_set_iter (pr, res, set_iter);
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
R_INT (pr) = P_INT (pr, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_as_string (progs_t *pr, set_resources_t *res, pr_int_t setid)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_t *set = get_set (pr, res, __FUNCTION__, setid);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
RETURN_STRING (pr, set_as_string (set->set));
|
|
|
|
}
|
|
|
|
|
2022-02-04 13:19:05 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_as_string (progs_t *pr, void *_res)
|
2022-02-04 13:19:05 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
|
|
|
rua_set_as_string (pr, res, P_INT (pr, 0));
|
2022-02-04 13:19:05 +00:00
|
|
|
}
|
|
|
|
|
2012-12-16 04:48:36 +00:00
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_SetIterator__element (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2012-12-16 04:48:36 +00:00
|
|
|
pr_set_iter_t *iter_obj = &P_STRUCT (pr, pr_set_iter_t, 0);
|
2022-02-14 03:28:38 +00:00
|
|
|
bi_set_iter_t *set_iter = get_set_iter (pr, res, __FUNCTION__,
|
|
|
|
iter_obj->iter);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2012-12-21 05:09:00 +00:00
|
|
|
R_INT (pr) = set_iter->iter->element;
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__add_ (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t set_ptr = P_POINTER (pr, 0);
|
|
|
|
pr_set_t *set_obj = &G_STRUCT (pr, pr_set_t, set_ptr);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_add (pr, res, set_obj->set, P_UINT (pr, 2));
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = set_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__remove_ (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t set_ptr = P_POINTER (pr, 0);
|
|
|
|
pr_set_t *set_obj = &G_STRUCT (pr, pr_set_t, set_ptr);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_remove (pr, res, set_obj->set, P_UINT (pr, 2));
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = set_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__invert (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t set_ptr = P_POINTER (pr, 0);
|
|
|
|
pr_set_t *set_obj = &G_STRUCT (pr, pr_set_t, set_ptr);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_invert (pr, res, set_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = set_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__union_ (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t dst_ptr = P_POINTER (pr, 0);
|
|
|
|
pr_set_t *dst_obj = &G_STRUCT (pr, pr_set_t, dst_ptr);
|
2022-02-04 13:19:05 +00:00
|
|
|
pr_set_t *src_obj = &P_STRUCT (pr, pr_set_t, 2);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_union (pr, res, dst_obj->set, src_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__intersection_ (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t dst_ptr = P_POINTER (pr, 0);
|
|
|
|
pr_set_t *dst_obj = &G_STRUCT (pr, pr_set_t, dst_ptr);
|
|
|
|
pr_set_t *src_obj = &P_STRUCT (pr, pr_set_t, 2);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_intersection (pr, res, dst_obj->set, src_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = dst_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__difference_ (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t dst_ptr = P_POINTER (pr, 0);
|
|
|
|
pr_set_t *dst_obj = &G_STRUCT (pr, pr_set_t, dst_ptr);
|
|
|
|
pr_set_t *src_obj = &P_STRUCT (pr, pr_set_t, 2);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_difference (pr, res, dst_obj->set, src_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = dst_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__reverse_difference_ (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t dst_ptr = P_POINTER (pr, 0);
|
|
|
|
pr_set_t *dst_obj = &G_STRUCT (pr, pr_set_t, dst_ptr);
|
|
|
|
pr_set_t *src_obj = &P_STRUCT (pr, pr_set_t, 2);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_reverse_difference (pr, res, dst_obj->set, src_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = dst_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__assign_ (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t dst_ptr = P_POINTER (pr, 0);
|
|
|
|
pr_set_t *dst_obj = &G_STRUCT (pr, pr_set_t, dst_ptr);
|
|
|
|
pr_set_t *src_obj = &P_STRUCT (pr, pr_set_t, 2);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_assign (pr, res, dst_obj->set, src_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = dst_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__empty (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t set_ptr = P_POINTER (pr, 0);
|
|
|
|
pr_set_t *set_obj = &G_STRUCT (pr, pr_set_t, set_ptr);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_empty (pr, res, set_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = set_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__everything (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t set_ptr = P_POINTER (pr, 0);
|
|
|
|
pr_set_t *set_obj = &G_STRUCT (pr, pr_set_t, set_ptr);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_everything (pr, res, set_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
R_INT (pr) = set_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__is_empty (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2012-12-16 04:48:36 +00:00
|
|
|
pr_set_t *set_obj = &P_STRUCT (pr, pr_set_t, 0);
|
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_empty (pr, res, set_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__is_everything (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2012-12-16 04:48:36 +00:00
|
|
|
pr_set_t *set_obj = &P_STRUCT (pr, pr_set_t, 0);
|
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_everything (pr, res, set_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__is_disjoint_ (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2012-12-16 04:48:36 +00:00
|
|
|
pr_set_t *s1_obj = &P_STRUCT (pr, pr_set_t, 0);
|
|
|
|
pr_set_t *s2_obj = &P_STRUCT (pr, pr_set_t, 2);
|
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_disjoint (pr, res, s1_obj->set, s2_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__is_intersecting_ (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2012-12-16 04:48:36 +00:00
|
|
|
pr_set_t *s1_obj = &P_STRUCT (pr, pr_set_t, 0);
|
|
|
|
pr_set_t *s2_obj = &P_STRUCT (pr, pr_set_t, 2);
|
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_intersecting (pr, res, s1_obj->set, s2_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__is_equivalent_ (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2012-12-16 04:48:36 +00:00
|
|
|
pr_set_t *s1_obj = &P_STRUCT (pr, pr_set_t, 0);
|
|
|
|
pr_set_t *s2_obj = &P_STRUCT (pr, pr_set_t, 2);
|
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_equivalent (pr, res, s1_obj->set, s2_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__is_subset_ (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2022-02-04 13:19:05 +00:00
|
|
|
pr_set_t *set_obj = &P_STRUCT (pr, pr_set_t, 0);
|
|
|
|
pr_set_t *sub_obj = &P_STRUCT (pr, pr_set_t, 2);
|
2012-12-16 04:48:36 +00:00
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_subset (pr, res, set_obj->set, sub_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__is_member_ (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2012-12-16 04:48:36 +00:00
|
|
|
pr_set_t *set_obj = &P_STRUCT (pr, pr_set_t, 0);
|
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_is_member (pr, res, set_obj->set, P_UINT (pr, 2));
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__size (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2012-12-16 04:48:36 +00:00
|
|
|
pr_set_t *set_obj = &P_STRUCT (pr, pr_set_t, 0);
|
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_count (pr, res, set_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
bi__i_Set__as_string (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = _res;
|
2012-12-16 04:48:36 +00:00
|
|
|
pr_set_t *set_obj = &P_STRUCT (pr, pr_set_t, 0);
|
|
|
|
|
2022-02-14 03:28:38 +00:00
|
|
|
rua_set_as_string (pr, res, set_obj->set);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 03:28:38 +00:00
|
|
|
res_set_clear (progs_t *pr, void *_res)
|
2012-12-16 04:48:36 +00:00
|
|
|
{
|
2022-02-14 03:28:38 +00:00
|
|
|
set_resources_t *res = (set_resources_t *) _res;
|
2012-12-16 04:48:36 +00:00
|
|
|
bi_set_t *set;
|
|
|
|
bi_set_iter_t *set_iter;
|
|
|
|
|
|
|
|
for (set = res->sets; set; set = set->next)
|
|
|
|
set_delete (set->set);
|
|
|
|
for (set_iter = res->set_iters; set_iter; set_iter = set_iter->next)
|
|
|
|
set_del_iter (set_iter->iter);
|
|
|
|
res->sets = 0;
|
|
|
|
res->set_iters = 0;
|
|
|
|
res_set_reset (res);
|
|
|
|
res_set_iter_reset (res);
|
|
|
|
}
|
|
|
|
|
2022-05-12 09:23:32 +00:00
|
|
|
static void
|
|
|
|
res_set_destroy (progs_t *pr, void *_res)
|
|
|
|
{
|
2023-03-03 10:36:28 +00:00
|
|
|
free (_res);
|
2022-05-12 09:23:32 +00:00
|
|
|
}
|
|
|
|
|
2022-01-23 12:54:03 +00:00
|
|
|
#define bi(x,np,params...) {#x, bi_##x, -1, np, {params}}
|
|
|
|
#define p(type) PR_PARAM(type)
|
2012-12-16 04:48:36 +00:00
|
|
|
static builtin_t builtins[] = {
|
2022-01-23 12:54:03 +00:00
|
|
|
bi(set_del_iter, 1, p(ptr)),
|
|
|
|
bi(set_iter_element, 1, p(ptr)),
|
|
|
|
bi(set_new, 0),
|
|
|
|
bi(set_delete, 1, p(ptr)),
|
|
|
|
bi(set_add, 2, p(ptr), p(uint)),
|
|
|
|
bi(set_remove, 2, p(ptr), p(uint)),
|
|
|
|
bi(set_invert, 1, p(ptr)),
|
|
|
|
bi(set_union, 2, p(ptr), p(ptr)),
|
|
|
|
bi(set_intersection, 2, p(ptr), p(ptr)),
|
|
|
|
bi(set_difference, 2, p(ptr), p(ptr)),
|
|
|
|
bi(set_reverse_difference, 2, p(ptr), p(ptr)),
|
|
|
|
bi(set_assign, 2, p(ptr), p(ptr)),
|
|
|
|
bi(set_empty, 1, p(ptr)),
|
|
|
|
bi(set_everything, 1, p(ptr)),
|
|
|
|
bi(set_is_empty, 1, p(ptr)),
|
|
|
|
bi(set_is_everything, 1, p(ptr)),
|
|
|
|
bi(set_is_disjoint, 2, p(ptr), p(ptr)),
|
|
|
|
bi(set_is_intersecting, 2, p(ptr), p(ptr)),
|
|
|
|
bi(set_is_equivalent, 2, p(ptr), p(ptr)),
|
|
|
|
bi(set_is_subset, 2, p(ptr), p(ptr)),
|
|
|
|
bi(set_is_member, 2, p(ptr), p(uint)),
|
|
|
|
bi(set_count, 1, p(ptr)),
|
|
|
|
bi(set_first, 1, p(ptr)),
|
|
|
|
bi(set_next, 1, p(ptr)),
|
|
|
|
bi(set_as_string, 1, p(ptr)),
|
|
|
|
|
|
|
|
bi(_i_SetIterator__element, 2, p(ptr), p(ptr)),
|
|
|
|
|
|
|
|
bi(_i_Set__add_, 3, p(ptr), p(ptr), p(uint)),
|
|
|
|
bi(_i_Set__remove_, 3, p(ptr), p(ptr), p(uint)),
|
|
|
|
bi(_i_Set__invert, 2, p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__union_, 3, p(ptr), p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__intersection_, 3, p(ptr), p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__difference_, 3, p(ptr), p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__reverse_difference_, 3, p(ptr), p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__assign_, 3, p(ptr), p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__empty, 2, p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__everything, 2, p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__is_empty, 2, p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__is_everything, 2, p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__is_disjoint_, 3, p(ptr), p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__is_intersecting_, 3, p(ptr), p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__is_equivalent_, 3, p(ptr), p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__is_subset_, 3, p(ptr), p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__is_member_, 3, p(ptr), p(ptr), p(uint)),
|
|
|
|
bi(_i_Set__size, 2, p(ptr), p(ptr)),
|
|
|
|
bi(_i_Set__as_string, 2, p(ptr), p(ptr)),
|
2012-12-16 04:48:36 +00:00
|
|
|
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
RUA_Set_Init (progs_t *pr, int secure)
|
|
|
|
{
|
|
|
|
set_resources_t *res = calloc (1, sizeof (set_resources_t));
|
|
|
|
res->sets = 0;
|
|
|
|
|
2022-05-12 09:23:32 +00:00
|
|
|
PR_Resources_Register (pr, "Set", res, res_set_clear, res_set_destroy);
|
2022-01-23 15:20:05 +00:00
|
|
|
PR_RegisterBuiltins (pr, builtins, res);
|
2012-12-16 04:48:36 +00:00
|
|
|
}
|