* [POLICYREP] [patch 0/7] various cleanups and base symbol class
@ 2008-01-22 19:43 Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 1/7] remove makefile targets that dont build Joshua Brindle
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Joshua Brindle @ 2008-01-22 19:43 UTC (permalink / raw)
To: selinux; +Cc: sds, kmacmillan, tmiller
do various fixups/cleanups and add a base symbol class for all symbols. This lays much of the groundwork for upcoming patches.
--
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [POLICYREP] [patch 1/7] remove makefile targets that dont build
2008-01-22 19:43 [POLICYREP] [patch 0/7] various cleanups and base symbol class Joshua Brindle
@ 2008-01-22 19:43 ` Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 2/7] remove policy_package Joshua Brindle
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Joshua Brindle @ 2008-01-22 19:43 UTC (permalink / raw)
To: selinux; +Cc: sds, kmacmillan, tmiller
temporarilly remove targets that don't build with policyrep
---
policycoreutils/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- policyrep.new.orig/policycoreutils/Makefile
+++ policyrep.new/policycoreutils/Makefile
@@ -1,4 +1,5 @@
-SUBDIRS=setfiles semanage load_policy newrole run_init restorecond secon audit2allow audit2why scripts sestatus semodule_package semodule semodule_link semodule_expand semodule_deps setsebool po
+SUBDIRS=setfiles load_policy newrole run_init restorecond secon audit2allow audit2why scripts sestatus po
+#setsebool semodule_package semanage semodule semodule_link semodule_expand semodule_deps
all install relabel clean indent:
@for subdir in $(SUBDIRS); do \
--
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [POLICYREP] [patch 2/7] remove policy_package
2008-01-22 19:43 [POLICYREP] [patch 0/7] various cleanups and base symbol class Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 1/7] remove makefile targets that dont build Joshua Brindle
@ 2008-01-22 19:43 ` Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 3/7] remove duplicated optional.hpp data Joshua Brindle
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Joshua Brindle @ 2008-01-22 19:43 UTC (permalink / raw)
To: selinux; +Cc: sds, kmacmillan, tmiller
We chose to go with a flat text file format rather than an archive so remove the xar package bits
---
libpolicyrep/include/policyrep/policy_package.hpp | 72 ---
libpolicyrep/src/policy_package.cpp | 463 ----------------------
policycoreutils/semodule_package/Makefile | 2
3 files changed, 1 insertion(+), 536 deletions(-)
--- policyrep.new.orig/libpolicyrep/include/policyrep/policy_package.hpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Author: Joshua Brindle <method@manicmethod.com> */
-
-#ifndef __policy_package_hpp__
-#define __policy_package_hpp__
-
-#include <policyrep/policy.hpp>
-
-namespace policyrep {
-
-struct PolicyPackageImpl;
-
-class PolicyPackage {
-public:
- PolicyPackage();
- virtual ~ PolicyPackage();
-
- virtual Module & get_policy_module() const;
- virtual void set_policy_module(Module & module);
-
- virtual char *get_file_contexts() const;
- virtual void set_file_contexts(char *fc);
- virtual char *get_seusers() const;
- virtual void set_seusers(char *su);
- virtual char *get_user_extra() const;
- virtual void set_user_extra(char *ue);
- virtual char *get_netfilter_contexts() const;
- virtual void set_netfilter_contexts(char *nf);
-
- virtual void read(char *filename);
- // PolicyPackage.write does not currently work pending
- // a bug fix in xar
- virtual void write(char *filename);
-
-protected:
- void init();
- PolicyPackageImpl *impl;
-
-};
-
-// This is a simple archival class that allows a dumb packager
-// e.g., semodule_package to simply set the pathnames for each
-// file in the policy package and call create_archive.
-
-struct PolicyPackageArchiveImpl;
-
-class PolicyPackageArchive {
-public:
- PolicyPackageArchive();
- virtual ~ PolicyPackageArchive();
-
- virtual void set_mod_file(char *mod);
- virtual char *get_mod_file() const;
- virtual void set_fc_file(char *fc);
- virtual char *get_fc_file() const;
- virtual void set_seusers_file(char *su);
- virtual char *get_seusers_file() const;
- virtual void set_user_extra_file(char *ue);
- virtual char *get_user_extra_file() const;
- virtual void set_nc_file(char *nf);
- virtual char *get_nc_file() const;
-
- virtual void create_archive(char *filename);
-
-protected:
- void init();
- PolicyPackageArchiveImpl *impl;
-
-};
-
-} // namespace policyrep
-
-#endif
--- policyrep.new.orig/libpolicyrep/src/policy_package.cpp
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
- * Author : Joshua Brindle <method@manicmethod.com>
- *
- * Copyright (C) 2007 Tresys Technology, llc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-extern "C" {
-#include <xar/xar.h>
-#include <string.h>
-}
-
-#define SELINUX_XAR_PROPERTY "selinuxfiletype"
-
-#include <policyrep/parse.hpp>
-#include <policyrep/policy_package.hpp>
-#include <sstream>
-#include <iostream>
-#include <stdexcept>
-
-namespace policyrep {
-
-struct PolicyPackageImpl {
- Module & policy_module;
- char *file_contexts;
- char *seusers;
- char *user_extra;
- char *netfilter_contexts;
-};
-
-void PolicyPackage::init() {
- impl = new PolicyPackageImpl;
- impl->file_contexts = NULL;
- impl->seusers = NULL;
- impl->user_extra = NULL;
- impl->netfilter_contexts = NULL;
-}
-
-PolicyPackage::PolicyPackage() {
- init();
-}
-
-Module & PolicyPackage::get_policy_module() const {
- return impl->policy_module;
-}
-
-void PolicyPackage::set_policy_module(Module & module) {
- impl->policy_module = module;
-}
-
-char *PolicyPackage::get_file_contexts() const {
- return impl->file_contexts;
-}
-
-void PolicyPackage::set_file_contexts(char *fc) {
- impl->file_contexts = fc;
-}
-
-char *PolicyPackage::get_seusers() const {
- return impl->seusers;
-}
-
-void PolicyPackage::set_seusers(char *se) {
- impl->seusers = se;
-}
-
-char *PolicyPackage::get_user_extra() const {
- return impl->user_extra;
-}
-
-void PolicyPackage::set_user_extra(char *ue) {
- impl->user_extra = ue;
-}
-
-char *PolicyPackage::get_netfilter_contexts() const {
- return impl->netfilter_contexts;
-}
-
-void PolicyPackage::set_netfilter_contexts(char *nc) {
- impl->netfilter_contexts = nc;
-}
-
-void PolicyPackage::read(char *filename) {
- xar_t x;
- xar_file_t f;
- xar_iter_t i;
-
- i = xar_iter_new();
-
- if (i == NULL) {
- throw std::bad_alloc();
- }
-
- x = xar_open(filename, READ);
-
- if (x == NULL) {
- throw std::
- runtime_error("Unable to open policy package");
- }
-
- for (f = xar_file_first(x, i); f; f = xar_file_next(i)) {
- size_t sz;
- char *fbuf;
- const char *filetype;
- int32_t ret;
-
- ret = xar_extract_tobuffersz(x, f, &fbuf, &sz);
-
- if (ret) {
- // This can happen if the file is 0 bytes
- // or is a symlink, directory, etc. We might want
- // to put code here to check those cases and bail
- // but for now we just ignore them and continue.
- continue;
- }
-
- ret = xar_prop_get(f, SELINUX_XAR_PROPERTY, &filetype);
-
- if (ret) {
- xar_close(x);
- throw std::runtime_error("Error getting name property of file");
- }
-
- if (strcmp(filetype, "policy_module") == 0) {
- Parser p;
- // TODO add parser constructor that takes a char * and call here
- continue;
- } else if (strcmp(filetype, "file_contexts") == 0) {
- if (impl->file_contexts) {
- xar_close(x);
- throw std::range_error("Multiple file_contexts files in policy package");
- }
-
- impl->file_contexts = fbuf;
-
- continue;
- } else if (strcmp(filetype, "seusers") == 0) {
- if (impl->seusers) {
- xar_close(x);
- throw std::range_error("Multiple seusers files in policy package");
- }
-
- impl->seusers = fbuf;
-
- continue;
- } else if (strcmp(filetype, "user_extra") == 0) {
- if (impl->user_extra) {
- xar_close(x);
- throw std::range_error("Multiple user_extra files in policy package");
- }
-
- impl->user_extra = fbuf;
-
- continue;
- } else if (strcmp(filetype, "netfilter_contexts") == 0) {
- if (impl->netfilter_contexts) {
- xar_close(x);
- throw std::range_error("Multiple netfilter_contexts files in policy package");
- }
-
- impl->netfilter_contexts = fbuf;
-
- continue;
- } else {
- // unrecognized file, just skip it
- free(fbuf);
- continue;
- }
-
- }
-
- xar_close(x);
-}
-
-void PolicyPackage::write(char *filename) {
-
- // just return -1 for now, this method exposes a xar bug and won't
- // work until the bug is fixed.
-
- return;
-
- xar_t x;
- xar_file_t f;
-
- x = xar_open(filename, WRITE);
-
- if (x == NULL) {
- throw std::
- runtime_error("Unable to open policy package");
- }
-
- if (!impl->policy_module.get_name().empty()) {
- std::stringstream s;
- char *buf;
-
- // TODO fix this when the output system has been updated - jjb
-#if 0
- output_tree(s, impl->policy_module);
-
- if (s.str().empty()) {
- throw std::runtime_error("Error serializing module");
- }
-
- buf = strdup(s.str().c_str());
-
- f = xar_add_frombuffer(x, NULL, "policy_module", buf, s.str().length());
- free(buf);
-
- if (!f) {
- xar_close(x);
- throw std::runtime_error("Error writing policy module to policy package");
- }
-
- if (xar_prop_set(f, SELINUX_XAR_PROPERTY, "policy_module")) {
- xar_close(x);
- throw std::runtime_error("Error setting policy_module property in policy package");
- }
-
-#endif
- }
-
- if (impl->file_contexts) {
- f = xar_add_frombuffer(x, NULL, "file_contexts",
- impl->file_contexts,
- strlen(impl->file_contexts));
-
- if (!f) {
- xar_close(x);
- throw std::runtime_error("Error writing file_contexts to policy package");
- }
-
- if (xar_prop_set(f, SELINUX_XAR_PROPERTY, "file_contexts")) {
- xar_close(x);
- throw std::runtime_error("Error setting file_contexts property in policy package");
- }
- }
-
- if (impl->seusers) {
- f = xar_add_frombuffer(x, NULL, "seusers",
- impl->seusers,
- strlen(impl->seusers));
-
- if (!f) {
- xar_close(x);
- throw std::runtime_error("Error writing seusers to policy package");
- }
-
- if (xar_prop_set(f, SELINUX_XAR_PROPERTY, "seusers")) {
- xar_close(x);
- throw std::runtime_error("Error setting seusers property in policy package");
- }
- }
-
- if (impl->user_extra) {
- f = xar_add_frombuffer(x, NULL, "user_extra",
- impl->user_extra,
- strlen(impl->user_extra));
-
- if (!f) {
- xar_close(x);
- throw std::runtime_error("Error writing user_extra to policy package");
- }
-
- if (xar_prop_set(f, SELINUX_XAR_PROPERTY, "user_extra")) {
- xar_close(x);
- throw std::runtime_error("Error setting user_extra property in policy package");
- }
- }
-
- if (impl->netfilter_contexts) {
- f = xar_add_frombuffer(x, NULL, "netfilter_contexts",
- impl->netfilter_contexts,
- strlen(impl->
- netfilter_contexts));
-
- if (!f) {
- xar_close(x);
- throw std::runtime_error("Error writing netfilter_contexts to policy package");
- }
-
- if (xar_prop_set(f, SELINUX_XAR_PROPERTY, "netfilter_contexts")) {
- xar_close(x);
- throw std::runtime_error("Error setting netfilter_contexts property in policy package");
- }
- }
-
- xar_close(x);
-}
-
-PolicyPackage::~PolicyPackage() {
- delete impl;
-}
-
-//
-// PolicyPackageArchive
-// This class is used for creating a policy package file from individual files.
-// Set the filenames for each kind of file (module, file_contexts, etc) then
-// call create_archive.
-
-struct PolicyPackageArchiveImpl {
- char *mod_file;
- char *fc_file;
- char *seusers_file;
- char *user_extra_file;
- char *nc_file;
-};
-
-void PolicyPackageArchive::init() {
- impl = new PolicyPackageArchiveImpl;
- impl->mod_file = NULL;
- impl->fc_file = NULL;
- impl->seusers_file = NULL;
- impl->user_extra_file = NULL;
- impl->nc_file = NULL;
-}
-
-PolicyPackageArchive::PolicyPackageArchive() {
- init();
-}
-
-void PolicyPackageArchive::set_mod_file(char *mod) {
- impl->mod_file = mod;
-}
-
-char *PolicyPackageArchive::get_mod_file() const {
- return impl->mod_file;
-}
-
-void PolicyPackageArchive::set_fc_file(char *fc) {
- impl->fc_file = fc;
-}
-
-char *PolicyPackageArchive::get_fc_file() const {
- return impl->fc_file;
-}
-
-void PolicyPackageArchive::set_seusers_file(char *su) {
- impl->seusers_file = su;
-}
-
-char *PolicyPackageArchive::get_seusers_file() const {
- return impl->seusers_file;
-}
-
-void PolicyPackageArchive::set_user_extra_file(char *ue) {
- impl->user_extra_file = ue;
-}
-
-char *PolicyPackageArchive::get_user_extra_file() const {
- return impl->user_extra_file;
-}
-
-void PolicyPackageArchive::set_nc_file(char *nc) {
- impl->nc_file = nc;
-}
-
-char *PolicyPackageArchive::get_nc_file() const {
- return impl->nc_file;
-}
-
-void PolicyPackageArchive::create_archive(char *filename) {
- xar_t x;
- xar_file_t f;
-
- x = xar_open(filename, WRITE);
-
- if (x == NULL) {
- throw std::runtime_error("Unable to open policy package");
- }
-
- if (impl->mod_file) {
- f = xar_add(x, impl->mod_file);
-
- if (!f) {
- xar_close(x);
- throw std::runtime_error("Error writing module to policy package");
- }
-
- if (xar_prop_set(f, SELINUX_XAR_PROPERTY, "module")) {
- xar_close(x);
- throw std::runtime_error("Error setting module property in policy package");
- }
- }
-
- if (impl->fc_file) {
- f = xar_add(x, impl->fc_file);
-
- if (!f) {
- xar_close(x);
- throw std::runtime_error("Error writing file_contexts to policy package");
- }
-
- if (xar_prop_set
- (f, SELINUX_XAR_PROPERTY, "file_contexts")) {
- xar_close(x);
- throw std::runtime_error("Error setting file_contexts property in policy package");
- }
- }
-
- if (impl->seusers_file) {
- f = xar_add(x, impl->seusers_file);
-
- if (!f) {
- xar_close(x);
- throw std::runtime_error("Error writing seusers to policy package");
- }
-
- if (xar_prop_set(f, SELINUX_XAR_PROPERTY, "seusers")) {
- xar_close(x);
- throw std::runtime_error("Error setting seusers property in policy package");
- }
- }
-
- if (impl->user_extra_file) {
- f = xar_add(x, impl->user_extra_file);
-
- if (!f) {
- xar_close(x);
- throw std::runtime_error("Error writing user_extra to policy package");
- }
-
- if (xar_prop_set(f, SELINUX_XAR_PROPERTY, "user_extra")) {
- xar_close(x);
- throw std::runtime_error("Error setting user_extra property in policy package");
- }
- }
-
- if (impl->nc_file) {
- f = xar_add(x, impl->nc_file);
-
- if (!f) {
- xar_close(x);
- throw std::runtime_error("Error writing netfilter_contexts to policy package");
- }
-
- if (xar_prop_set
- (f, SELINUX_XAR_PROPERTY, "netfilter_contexts")) {
- xar_close(x);
- throw std::runtime_error("Error setting netfilter_contexts property in policy package");
- }
- }
-
- xar_close(x);
-}
-
-PolicyPackageArchive::~PolicyPackageArchive() {
- delete impl;
-}
-
-} // namespace policyrep
--- policyrep.new.orig/policycoreutils/semodule_package/Makefile
+++ policyrep.new/policycoreutils/semodule_package/Makefile
@@ -7,7 +7,7 @@ MANDIR ?= $(PREFIX)/share/man
CFLAGS ?= -Werror -Wall -W
override CFLAGS += -I$(INCLUDEDIR)
-LDLIBS = -lpolicyrep -lxar -lselinux -L$(LIBDIR)
+LDLIBS = -lpolicyrep -lselinux -L$(LIBDIR)
all: semodule_package
--
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [POLICYREP] [patch 3/7] remove duplicated optional.hpp data
2008-01-22 19:43 [POLICYREP] [patch 0/7] various cleanups and base symbol class Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 1/7] remove makefile targets that dont build Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 2/7] remove policy_package Joshua Brindle
@ 2008-01-22 19:43 ` Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 4/7] symbol base class Joshua Brindle
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Joshua Brindle @ 2008-01-22 19:43 UTC (permalink / raw)
To: selinux; +Cc: sds, kmacmillan, tmiller
Somehow optional.hpp ended up duplicated twice, remove the extra junk
---
libpolicyrep/include/policyrep/optional.hpp | 46 ----------------------------
1 file changed, 46 deletions(-)
--- policyrep.new.orig/libpolicyrep/include/policyrep/optional.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/optional.hpp
@@ -44,49 +44,3 @@ namespace policyrep
} // namespace policyrep
#endif
-/* Author: Karl MacMillan <kmacmillan@mentalrootkit.com> */
-
-#ifndef __optional_hpp__
-#define __optional_hpp__
-
-#include <policyrep/policy_base.hpp>
-
-namespace policyrep
-{
- class OptionalBranch;
- typedef boost::shared_ptr<OptionalBranch> OptionalBranchPtr;
-
- struct OptionalBlockImpl;
- class OptionalBlock : public PolicyBlock
- {
- public:
- OptionalBlock();
- OptionalBlock(const OptionalBlock& other);
- OptionalBlock(OptionalBranchPtr true_);
- OptionalBlock(OptionalBranchPtr true_, OptionalBranchPtr false_);
- virtual ~OptionalBlock();
- virtual void operator=(const OptionalBlock& other);
- protected:
- void copy(const OptionalBlock& other);
- OptionalBlockImpl* impl;
- };
- typedef boost::shared_ptr<OptionalBlock> OptionalBlockPtr;
-
- struct OptionalBranchImpl;
- class OptionalBranch : public PolicyBranch
- {
- public:
- OptionalBranch();
- OptionalBranch(const OptionalBranch& other);
- virtual ~OptionalBranch();
- virtual void operator=(const OptionalBranch& other);
-
- protected:
- virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void copy(const OptionalBranch& other);
- OptionalBranchImpl* impl;
- };
-
-} // namespace policyrep
-
-#endif
--
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [POLICYREP] [patch 4/7] symbol base class
2008-01-22 19:43 [POLICYREP] [patch 0/7] various cleanups and base symbol class Joshua Brindle
` (2 preceding siblings ...)
2008-01-22 19:43 ` [POLICYREP] [patch 3/7] remove duplicated optional.hpp data Joshua Brindle
@ 2008-01-22 19:43 ` Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 5/7] fix operator= calls to return pointer Joshua Brindle
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Joshua Brindle @ 2008-01-22 19:43 UTC (permalink / raw)
To: selinux; +Cc: sds, kmacmillan, tmiller
This adds the symbol base class and makes all symbols (types, roles, etc) inherit from it.
---
libpolicyrep/include/policyrep/conditional.hpp | 5 -
libpolicyrep/include/policyrep/mls.hpp | 16 +---
libpolicyrep/include/policyrep/object_class.hpp | 10 +--
libpolicyrep/include/policyrep/policy.hpp | 6 -
libpolicyrep/include/policyrep/rbac.hpp | 6 -
libpolicyrep/include/policyrep/symbol.hpp | 27 ++++++++
libpolicyrep/include/policyrep/te_decl.hpp | 10 ---
libpolicyrep/include/policyrep/user.hpp | 6 -
libpolicyrep/src/conditional.cpp | 21 +-----
libpolicyrep/src/mls.cpp | 78 ++++++++----------------
libpolicyrep/src/object_class.cpp | 42 ++++--------
libpolicyrep/src/policy.cpp | 20 +-----
libpolicyrep/src/rbac.cpp | 27 +++-----
libpolicyrep/src/symbol.cpp | 71 +++++++++++++++++++++
libpolicyrep/src/te_decl.cpp | 52 +++++-----------
libpolicyrep/src/user.cpp | 27 +++-----
16 files changed, 206 insertions(+), 218 deletions(-)
--- policyrep.new.orig/libpolicyrep/include/policyrep/conditional.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/conditional.hpp
@@ -4,6 +4,7 @@
#define __conditional_hpp__
#include <policyrep/policy_base.hpp>
+#include <policyrep/symbol.hpp>
#include <list>
@@ -39,7 +40,7 @@ namespace policyrep
*/
struct CondBoolImpl;
- class CondBool : public Node
+ class CondBool : public Symbol
{
public:
CondBool();
@@ -48,8 +49,6 @@ namespace policyrep
virtual ~CondBool();
virtual void operator=(const CondBool& other);
- virtual void set_name(const std::string& name);
- virtual const std::string& get_name() const;
virtual void set_default_value(bool v);
virtual bool get_default_value() const;
--- policyrep.new.orig/libpolicyrep/include/policyrep/mls.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/mls.hpp
@@ -4,6 +4,7 @@
#define __mls_hpp__
#include <policyrep/policy_base.hpp>
+#include <policyrep/symbol.hpp>
namespace policyrep
{
@@ -13,7 +14,7 @@ namespace policyrep
//
struct SensitivityImpl;
- class Sensitivity : public Node
+ class Sensitivity : public Symbol
{
public:
Sensitivity();
@@ -30,9 +31,6 @@ namespace policyrep
aliases().insert(begin, end);
}
- virtual const std::string& get_name() const;
- virtual void set_name(const std::string& name);
-
virtual StringSet& aliases();
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
@@ -74,7 +72,7 @@ namespace policyrep
//
struct CategoryImpl;
- class Category : public Node
+ class Category : public Symbol
{
public:
Category();
@@ -91,9 +89,6 @@ namespace policyrep
aliases().insert(begin, end);
}
- virtual const std::string& get_name() const;
- virtual void set_name(const std::string& name);
-
virtual StringSet& aliases();
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
@@ -107,7 +102,7 @@ namespace policyrep
//
struct LevelImpl;
- class Level : public Node
+ class Level : public Symbol
{
public:
Level();
@@ -124,9 +119,6 @@ namespace policyrep
categories().insert(begin, end);
}
- virtual const std::string& get_name() const;
- virtual void set_name(const std::string& name);
-
virtual StringSet& categories();
virtual void do_output_brief(std::ostream& o, const OutputFormatter& op) const;
protected:
--- policyrep.new.orig/libpolicyrep/include/policyrep/object_class.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/object_class.hpp
@@ -4,6 +4,7 @@
#define __object_class_hpp__
#include <policyrep/policy_base.hpp>
+#include <policyrep/symbol.hpp>
namespace policyrep
{
@@ -13,7 +14,7 @@ namespace policyrep
//
struct CommonPermsImpl;
- class CommonPerms : public Node
+ class CommonPerms : public Symbol
{
public:
CommonPerms();
@@ -29,8 +30,6 @@ namespace policyrep
perms().insert(perms_begin, perms_end);
}
- virtual const std::string& get_name() const;
- virtual void set_name(const std::string& name);
virtual StringSet& perms();
protected:
@@ -46,10 +45,11 @@ namespace policyrep
//
struct ObjectClassImpl;
- class ObjectClass : public Node
+ class ObjectClass : public Symbol
{
public:
ObjectClass();
+ ObjectClass(const std::string& name);
ObjectClass(const std::string& name, const std::string& commons);
ObjectClass(const ObjectClass& other);
virtual ~ObjectClass();
@@ -65,8 +65,6 @@ namespace policyrep
perms().insert(perms_begin, perms_end);
}
- virtual const std::string& get_name() const;
- virtual void set_name(const std::string& name);
virtual StringSet& perms();
virtual const std::string& get_common_perms() const;
virtual void set_common_perms(const std::string& name);
--- policyrep.new.orig/libpolicyrep/include/policyrep/policy.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/policy.hpp
@@ -12,6 +12,7 @@
#include <policyrep/user.hpp>
#include <policyrep/mls.hpp>
#include <policyrep/optional.hpp>
+#include <policyrep/symbol.hpp>
namespace policyrep
{
@@ -69,7 +70,7 @@ namespace policyrep
//
struct InitialSidImpl;
- class InitialSid : public Node
+ class InitialSid : public Symbol
{
public:
InitialSid();
@@ -78,9 +79,6 @@ namespace policyrep
virtual ~InitialSid();
virtual void operator=(const InitialSid& other);
- virtual const std::string& get_name() const;
- virtual void set_name(const std::string& name);
-
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
void copy(const InitialSid& other);
--- policyrep.new.orig/libpolicyrep/include/policyrep/rbac.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/rbac.hpp
@@ -4,6 +4,7 @@
#define __role_hpp__
#include <policyrep/policy_base.hpp>
+#include <policyrep/symbol.hpp>
namespace policyrep
{
@@ -13,7 +14,7 @@ namespace policyrep
//
struct RoleImpl;
- class Role : public Node
+ class Role : public Symbol
{
public:
Role();
@@ -30,9 +31,6 @@ namespace policyrep
types().insert(types_begin, end);
}
- virtual const std::string& get_name() const;
- virtual void set_name(const std::string& name);
-
virtual StringSet& types();
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
--- /dev/null
+++ policyrep.new/libpolicyrep/include/policyrep/symbol.hpp
@@ -0,0 +1,27 @@
+/* Author: Jeremy A. Mowery <jmowery@tresys.com> */
+
+#ifndef __symbol_hpp__
+#define __symbol_hpp__
+
+#include <policyrep/policy_base.hpp>
+
+namespace policyrep
+{
+ struct SymbolImpl;
+ class Symbol : public Node
+ {
+ public:
+ typedef boost::shared_ptr<Symbol> Ptr;
+ Symbol();
+ Symbol(const std::string & name);
+ Symbol(const Symbol & other);
+ virtual ~Symbol();
+ const std::string & get_name() const;
+ std::string& set_name(const std::string & name);
+ virtual Symbol & operator=(const Symbol & other);
+ private:
+ SymbolImpl * _symbol_impl;
+ };
+}
+
+#endif /* __symbol_hpp__ */
--- policyrep.new.orig/libpolicyrep/include/policyrep/te_decl.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/te_decl.hpp
@@ -4,6 +4,7 @@
#define __te_decl_hpp__
#include <policyrep/policy_base.hpp>
+#include <policyrep/symbol.hpp>
namespace policyrep
{
@@ -13,7 +14,7 @@ namespace policyrep
//
struct TypeImpl;
- class Type : public Node
+ class Type : public Symbol
{
public:
Type();
@@ -40,9 +41,6 @@ namespace policyrep
aliases().insert(aliases_begin, aliases_end);
}
- virtual const std::string& get_name() const;
- virtual void set_name(const std::string& name);
-
virtual StringSet& aliases();
virtual StringSet& attributes();
protected:
@@ -58,7 +56,7 @@ namespace policyrep
//
struct AttributeImpl;
- class Attribute : public Node
+ class Attribute : public Symbol
{
public:
Attribute();
@@ -67,8 +65,6 @@ namespace policyrep
virtual ~Attribute();
virtual void operator=(const Attribute& other);
- virtual const std::string& get_name() const;
- virtual void set_name(const std::string& name);
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
virtual void copy(const Attribute& other);
--- policyrep.new.orig/libpolicyrep/include/policyrep/user.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/user.hpp
@@ -5,6 +5,7 @@
#include <policyrep/policy_base.hpp>
#include <policyrep/mls.hpp>
+#include <policyrep/symbol.hpp>
namespace policyrep
{
@@ -14,7 +15,7 @@ namespace policyrep
//
struct UserImpl;
- class User : public Node
+ class User : public Symbol
{
public:
User();
@@ -43,9 +44,6 @@ namespace policyrep
set_range_high(high);
}
-
- virtual const std::string& get_name() const;
- virtual void set_name(const std::string& name);
virtual void set_level(LevelPtr level);
virtual void set_range_low(LevelPtr low);
virtual void set_range_high(LevelPtr high);
--- policyrep.new.orig/libpolicyrep/src/conditional.cpp
+++ policyrep.new/libpolicyrep/src/conditional.cpp
@@ -33,23 +33,21 @@ namespace policyrep
struct CondBoolImpl
{
- std::string name;
bool default_value;
};
- CondBool::CondBool() : impl(new CondBoolImpl)
+ CondBool::CondBool() : Symbol(), impl(new CondBoolImpl)
{
}
CondBool::CondBool(const std::string& name, bool v)
- : impl(new CondBoolImpl)
+ :Symbol(name), impl(new CondBoolImpl)
{
- impl->name = name;
impl->default_value = v;
}
- CondBool::CondBool(const CondBool& other) : Node(), impl(new CondBoolImpl)
+ CondBool::CondBool(const CondBool& other) : Symbol(other), impl(new CondBoolImpl)
{
copy(other);
}
@@ -61,19 +59,10 @@ namespace policyrep
void CondBool::operator=(const CondBool& other)
{
+ Symbol::operator=(other);
copy(other);
}
- void CondBool::set_name(const std::string& name)
- {
- impl->name = name;
- }
-
- const std::string& CondBool::get_name() const
- {
- return impl->name;
- }
-
void CondBool::set_default_value(bool v)
{
impl->default_value = v;
@@ -86,7 +75,7 @@ namespace policyrep
void CondBool::do_output(std::ostream& o, const OutputFormatter& op) const
{
- o << "bool " << impl->name << " ";
+ o << "bool " << get_name() << " ";
if (impl->default_value)
o << "true;";
else
--- policyrep.new.orig/libpolicyrep/src/mls.cpp
+++ policyrep.new/libpolicyrep/src/mls.cpp
@@ -29,7 +29,6 @@ namespace policyrep
struct SensitivityImpl
{
- std::string name;
StringSet aliases;
};
@@ -38,18 +37,22 @@ namespace policyrep
impl = new SensitivityImpl;
}
- Sensitivity::Sensitivity() { init(); }
+ Sensitivity::Sensitivity()
+ :Symbol()
+ {
+ impl = new SensitivityImpl;
+ }
Sensitivity::Sensitivity(const std::string& name)
+ :Symbol(name)
{
- init();
- impl->name = name;
+ impl = new SensitivityImpl;
}
Sensitivity::Sensitivity(const Sensitivity& other)
- : Node()
+ :Symbol(other)
{
- init();
+ impl = new SensitivityImpl;
*impl = *other.impl;
}
@@ -60,16 +63,6 @@ namespace policyrep
*impl = *other.impl;
}
- const std::string& Sensitivity::get_name() const
- {
- return impl->name;
- }
-
- void Sensitivity::set_name(const std::string& name)
- {
- impl->name = name;
- }
-
StringSet& Sensitivity::aliases()
{
return impl->aliases;
@@ -77,7 +70,7 @@ namespace policyrep
void Sensitivity::do_output(std::ostream& o, const OutputFormatter& op) const
{
- o << "sensitivity " << impl->name;
+ o << "sensitivity " << get_name();
if (!impl->aliases.empty()) {
o << " alias ";
bracket_output_container(o, impl->aliases.begin(),
@@ -137,7 +130,6 @@ namespace policyrep
struct CategoryImpl
{
- std::string name;
StringSet aliases;
};
@@ -146,16 +138,20 @@ namespace policyrep
impl = new CategoryImpl;
}
- Category::Category() { init(); }
+ Category::Category()
+ :Symbol()
+ {
+ impl = new CategoryImpl;
+ }
Category::Category(const std::string& name)
+ :Symbol(name)
{
- init();
- impl->name = name;
+ impl = new CategoryImpl;
}
Category::Category(const Category& other)
- : Node()
+ :Symbol(other)
{
init();
*impl = *other.impl;
@@ -168,16 +164,6 @@ namespace policyrep
*impl = *other.impl;
}
- const std::string& Category::get_name() const
- {
- return impl->name;
- }
-
- void Category::set_name(const std::string& name)
- {
- impl->name = name;
- }
-
StringSet& Category::aliases()
{
return impl->aliases;
@@ -185,7 +171,7 @@ namespace policyrep
void Category::do_output(std::ostream& o, const OutputFormatter& op) const
{
- o << "category " << impl->name;
+ o << "category " << get_name();
if (!impl->aliases.empty()) {
o << " alias ";
bracket_output_container(o, impl->aliases.begin(),
@@ -209,18 +195,22 @@ namespace policyrep
impl = new LevelImpl;
}
- Level::Level() { init(); }
+ Level::Level()
+ :Symbol()
+ {
+ impl = new LevelImpl;
+ }
Level::Level(const std::string& name)
+ :Symbol(name)
{
- init();
- impl->name = name;
+ impl = new LevelImpl;
}
Level::Level(const Level& other)
- : Node()
+ :Symbol(other)
{
- init();
+ impl = new LevelImpl;
*impl = *other.impl;
}
@@ -233,16 +223,6 @@ namespace policyrep
*impl = *other.impl;
}
- const std::string& Level::get_name() const
- {
- return impl->name;
- }
-
- void Level::set_name(const std::string& name)
- {
- impl->name = name;
- }
-
StringSet& Level::categories()
{
return impl->categories;
@@ -250,7 +230,7 @@ namespace policyrep
void Level::do_output_brief(std::ostream& o, const OutputFormatter& op) const
{
- o << impl->name;
+ o << get_name();
if (!impl->categories.empty()) {
o << ":";
bracket_output_container(o, impl->categories.begin(),
--- /dev/null
+++ policyrep.new/libpolicyrep/src/symbol.cpp
@@ -0,0 +1,71 @@
+/*
+ * Author : Jeremy A. Mowery <jmowery@tresys.com>
+ *
+ * Copyright (C) 2007 Tresys Technology, LLC.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <policyrep/symbol.hpp>
+
+namespace policyrep
+{
+ struct SymbolImpl
+ {
+ std::string name;
+ };
+
+ Symbol::Symbol()
+ :Node()
+ {
+ _symbol_impl = new SymbolImpl;
+ }
+
+ Symbol::Symbol(const std::string & name)
+ :Node()
+ {
+ _symbol_impl = new SymbolImpl;
+ _symbol_impl->name = name;
+ }
+
+ Symbol::Symbol(const Symbol & other)
+ :Node(other)
+ {
+ _symbol_impl = new SymbolImpl;
+ *_symbol_impl = *other._symbol_impl;
+ }
+
+ Symbol::~Symbol()
+ {
+ delete _symbol_impl;
+ }
+
+ const std::string & Symbol::get_name() const
+ {
+ return _symbol_impl->name;
+ }
+
+ std::string& Symbol::set_name(const std::string & name)
+ {
+ return _symbol_impl->name = name;
+ }
+
+ Symbol & Symbol::operator=(const Symbol & other)
+ {
+ Node::operator=(other);
+ *_symbol_impl = *other._symbol_impl;
+ return *this;
+ }
+}
--- policyrep.new.orig/libpolicyrep/src/object_class.cpp
+++ policyrep.new/libpolicyrep/src/object_class.cpp
@@ -28,7 +28,6 @@ namespace policyrep {
struct CommonPermsImpl
{
- std::string name;
StringSet perms;
};
@@ -37,10 +36,10 @@ namespace policyrep {
CommonPerms::CommonPerms() { init(); }
CommonPerms::CommonPerms(const CommonPerms& other)
- : Node()
+ :Symbol(other)
{
- init();
- copy(other);
+ impl = new CommonPermsImpl;
+ *impl = *other.impl;
}
CommonPerms::~CommonPerms()
@@ -53,16 +52,6 @@ namespace policyrep {
copy(other);
}
- const std::string& CommonPerms::get_name() const
- {
- return impl->name;
- }
-
- void CommonPerms::set_name(const std::string& name)
- {
- impl->name = name;
- }
-
StringSet& CommonPerms::perms()
{
return impl->perms;
@@ -70,7 +59,7 @@ namespace policyrep {
void CommonPerms::do_output(std::ostream& o, const OutputFormatter& op) const
{
- o << "common " << impl->name << " ";
+ o << "common " << get_name() << " ";
output_set_space(o, impl->perms);
}
@@ -86,7 +75,6 @@ namespace policyrep {
struct ObjectClassImpl
{
- std::string name;
StringSet perms;
std::string common_perms;
};
@@ -95,15 +83,21 @@ namespace policyrep {
ObjectClass::ObjectClass() { init(); }
+ ObjectClass::ObjectClass(const std::string &name)
+ :Symbol(name)
+ {
+ impl = new ObjectClassImpl;
+ }
+
ObjectClass::ObjectClass(const std::string& name, const std::string& commons)
+ :Symbol(name)
{
init();
- set_name(name);
set_common_perms(commons);
}
ObjectClass::ObjectClass(const ObjectClass& other)
- : Node()
+ :Symbol(other)
{
init();
copy(other);
@@ -119,16 +113,6 @@ namespace policyrep {
copy(other);
}
- const std::string& ObjectClass::get_name() const
- {
- return impl->name;
- }
-
- void ObjectClass::set_name(const std::string& name)
- {
- impl->name = name;
- }
-
StringSet& ObjectClass::perms()
{
return impl->perms;
@@ -146,7 +130,7 @@ namespace policyrep {
void ObjectClass::do_output(std::ostream& o, const OutputFormatter& op) const
{
- o << "class " << impl->name;
+ o << "class " << get_name();
if (impl->common_perms != "")
o << " inherits " << impl->common_perms;
if (!impl->perms.empty()) {
--- policyrep.new.orig/libpolicyrep/src/policy.cpp
+++ policyrep.new/libpolicyrep/src/policy.cpp
@@ -148,20 +148,18 @@ namespace policyrep
struct InitialSidImpl
{
- std::string name;
};
InitialSid::InitialSid()
- : impl(new InitialSidImpl) { }
+ :Symbol(), impl(new InitialSidImpl) { }
InitialSid::InitialSid(const std::string& name)
- : impl(new InitialSidImpl)
+ :Symbol(name), impl(new InitialSidImpl)
{
- impl->name = name;
}
InitialSid::InitialSid(const InitialSid& other)
- : Node(), impl(new InitialSidImpl)
+ : Symbol(other), impl(new InitialSidImpl)
{
copy(other);
}
@@ -173,19 +171,9 @@ namespace policyrep
copy(other);
}
- const std::string& InitialSid::get_name() const
- {
- return impl->name;
- }
-
- void InitialSid::set_name(const std::string& name)
- {
- impl->name = name;
- }
-
void InitialSid::do_output(std::ostream& o, const OutputFormatter& op) const
{
- o << "sid " << impl->name;
+ o << "sid " << get_name();
}
void InitialSid::copy(const InitialSid& other)
--- policyrep.new.orig/libpolicyrep/src/rbac.cpp
+++ policyrep.new/libpolicyrep/src/rbac.cpp
@@ -29,7 +29,6 @@ namespace policyrep
struct RoleImpl
{
- std::string name;
StringSet types;
};
@@ -38,18 +37,22 @@ namespace policyrep
impl = new RoleImpl;
}
- Role::Role() { init(); }
+ Role::Role()
+ :Symbol()
+ {
+ impl = new RoleImpl;
+ }
Role::Role(const std::string& name)
+ :Symbol(name)
{
- init();
- impl->name = name;
+ impl = new RoleImpl;
}
Role::Role(const Role& other)
- : Node()
+ :Symbol(other)
{
- init();
+ impl = new RoleImpl;
*impl = *other.impl;
}
@@ -60,16 +63,6 @@ namespace policyrep
*impl = *other.impl;
}
- const std::string& Role::get_name() const
- {
- return impl->name;
- }
-
- void Role::set_name(const std::string& name)
- {
- impl->name = name;
- }
-
StringSet& Role::types()
{
return impl->types;
@@ -77,7 +70,7 @@ namespace policyrep
void Role::do_output(std::ostream& o, const OutputFormatter& op) const
{
- o << "role " << impl->name;
+ o << "role " << get_name();
if (!impl->types.empty()) {
o << " types ";
output_set_comma(o, impl->types);
--- policyrep.new.orig/libpolicyrep/src/te_decl.cpp
+++ policyrep.new/libpolicyrep/src/te_decl.cpp
@@ -31,7 +31,6 @@ namespace policyrep
struct TypeImpl
{
- std::string name;
StringSet attributes;
StringSet aliases;
};
@@ -41,19 +40,23 @@ namespace policyrep
impl = new TypeImpl;
}
- Type::Type() { init(); }
+ Type::Type()
+ :Symbol()
+ {
+ impl = new TypeImpl;
+ }
Type::Type(const std::string& name)
+ :Symbol(name)
{
- init();
- impl->name = name;
+ impl = new TypeImpl;
}
Type::Type(const Type& other)
- : Node()
+ :Symbol(other)
{
- init();
- copy(other);
+ impl = new TypeImpl;
+ *impl = *other.impl;
}
Type::~Type() { delete impl; }
@@ -63,16 +66,6 @@ namespace policyrep
copy(other);
}
- const std::string& Type::get_name() const
- {
- return impl->name;
- }
-
- void Type::set_name(const std::string& name)
- {
- impl->name = name;
- }
-
StringSet& Type::aliases()
{
return impl->aliases;
@@ -85,7 +78,7 @@ namespace policyrep
void Type::do_output(std::ostream& o, const OutputFormatter& op) const
{
- o << "type " << impl->name;
+ o << "type " << get_name();
if (!impl->aliases.empty()) {
o << " alias ";
output_set_space(o, impl->aliases);
@@ -109,15 +102,16 @@ namespace policyrep
struct AttributeImpl
{
- std::string name;
};
- Attribute::Attribute() : impl(new AttributeImpl) { }
+ Attribute::Attribute()
+ :Symbol(), impl(new AttributeImpl)
+ {
+ }
Attribute::Attribute(const std::string& name)
- : impl(new AttributeImpl)
+ :Symbol(name), impl(new AttributeImpl)
{
- impl->name = name;
}
Attribute::~Attribute()
@@ -126,7 +120,7 @@ namespace policyrep
}
Attribute::Attribute(const Attribute& other)
- : Node(), impl(new AttributeImpl)
+ :Symbol(other), impl(new AttributeImpl)
{
copy(other);
}
@@ -136,19 +130,9 @@ namespace policyrep
copy(other);
}
- const std::string& Attribute::get_name() const
- {
- return impl->name;
- }
-
- void Attribute::set_name(const std::string& name)
- {
- impl->name = name;
- }
-
void Attribute::do_output(std::ostream& o, const OutputFormatter& op) const
{
- o << "attribute " << impl->name << ";";
+ o << "attribute " << get_name() << ";";
}
void Attribute::copy(const Attribute& other)
--- policyrep.new.orig/libpolicyrep/src/user.cpp
+++ policyrep.new/libpolicyrep/src/user.cpp
@@ -30,7 +30,6 @@ namespace policyrep
struct UserImpl
{
- std::string name;
LevelPtr level;
RangePtr range;
StringSet roles;
@@ -41,18 +40,22 @@ namespace policyrep
impl = new UserImpl;
}
- User::User() { init(); }
+ User::User()
+ :Symbol()
+ {
+ impl = new UserImpl;
+ }
User::User(const std::string& name)
+ :Symbol(name)
{
- init();
- impl->name = name;
+ impl = new UserImpl;
}
User::User(const User& other)
- : Node()
+ :Symbol(other)
{
- init();
+ impl = new UserImpl;
*impl = *other.impl;
}
@@ -65,16 +68,6 @@ namespace policyrep
*impl = *other.impl;
}
- const std::string& User::get_name() const
- {
- return impl->name;
- }
-
- void User::set_name(const std::string& name)
- {
- impl->name = name;
- }
-
StringSet& User::roles()
{
return impl->roles;
@@ -99,7 +92,7 @@ namespace policyrep
void User::do_output(std::ostream& o, const OutputFormatter& op) const
{
- o << "user " << impl->name;
+ o << "user " << get_name();
if (!impl->roles.empty()) {
o << " roles ";
output_set_comma(o, impl->roles);
--
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [POLICYREP] [patch 5/7] fix operator= calls to return pointer
2008-01-22 19:43 [POLICYREP] [patch 0/7] various cleanups and base symbol class Joshua Brindle
` (3 preceding siblings ...)
2008-01-22 19:43 ` [POLICYREP] [patch 4/7] symbol base class Joshua Brindle
@ 2008-01-22 19:43 ` Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 6/7] add negset to idset Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 7/7] remove unused copy/init functions Joshua Brindle
6 siblings, 0 replies; 9+ messages in thread
From: Joshua Brindle @ 2008-01-22 19:43 UTC (permalink / raw)
To: selinux; +Cc: sds, kmacmillan, tmiller
foo = bar is expected to return a pointer to the object being set, fix all classes to do this
---
libpolicyrep/include/policyrep/conditional.hpp | 8 +++---
libpolicyrep/include/policyrep/idset.hpp | 2 -
libpolicyrep/include/policyrep/mls.hpp | 10 ++++----
libpolicyrep/include/policyrep/object_class.hpp | 4 +--
libpolicyrep/include/policyrep/optional.hpp | 4 +--
libpolicyrep/include/policyrep/parse.hpp | 2 -
libpolicyrep/include/policyrep/policy.hpp | 6 ++--
libpolicyrep/include/policyrep/policy_base.hpp | 12 ++++-----
libpolicyrep/include/policyrep/rbac.hpp | 2 -
libpolicyrep/include/policyrep/rule.hpp | 4 +--
libpolicyrep/include/policyrep/te_decl.hpp | 8 +++---
libpolicyrep/include/policyrep/user.hpp | 2 -
libpolicyrep/src/conditional.cpp | 20 ++++++++++------
libpolicyrep/src/idset.cpp | 3 +-
libpolicyrep/src/mls.cpp | 12 ++++++---
libpolicyrep/src/object_class.cpp | 10 ++++----
libpolicyrep/src/optional.cpp | 12 ++++++---
libpolicyrep/src/parse.cpp | 3 +-
libpolicyrep/src/policy.cpp | 18 +++++++++-----
libpolicyrep/src/policy_base.cpp | 29 +++++++++++++++---------
libpolicyrep/src/rbac.cpp | 4 ++-
libpolicyrep/src/rule.cpp | 12 ++++++---
libpolicyrep/src/te_decl.cpp | 17 +++++++++-----
libpolicyrep/src/user.cpp | 3 +-
24 files changed, 126 insertions(+), 81 deletions(-)
--- policyrep.new.orig/libpolicyrep/include/policyrep/conditional.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/conditional.hpp
@@ -47,7 +47,7 @@ namespace policyrep
CondBool(const std::string& name, bool v);
CondBool(const CondBool& other);
virtual ~CondBool();
- virtual void operator=(const CondBool& other);
+ virtual CondBool& operator=(const CondBool& other);
virtual void set_default_value(bool v);
@@ -75,7 +75,7 @@ namespace policyrep
CondOp(Op op);
CondOp(const CondOp& other);
virtual ~CondOp();
- virtual void operator=(const CondOp& other);
+ virtual CondOp& operator=(const CondOp& other);
virtual void set_op(Op op);
virtual Op get_op() const;
@@ -113,7 +113,7 @@ namespace policyrep
CondBlock(CondBranchPtr if_, CondBranchPtr else_);
CondBlock(const CondBlock& other);
virtual ~CondBlock();
- virtual void operator=(const CondBlock& other);
+ virtual CondBlock& operator=(const CondBlock& other);
protected:
void copy(const CondBlock& other);
CondBlockImpl* impl;
@@ -130,7 +130,7 @@ namespace policyrep
CondBranch();
CondBranch(const CondBranch& other);
virtual ~CondBranch();
- virtual void operator=(const CondBranch& other);
+ virtual CondBranch& operator=(const CondBranch& other);
virtual CondExpr& expr();
protected:
--- policyrep.new.orig/libpolicyrep/include/policyrep/idset.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/idset.hpp
@@ -16,7 +16,7 @@ namespace policyrep
IdSet();
IdSet(const IdSet& other);
~IdSet();
- void operator=(const IdSet& other);
+ IdSet& operator=(const IdSet& other);
void set_compl(bool val);
bool get_compl() const;
--- policyrep.new.orig/libpolicyrep/include/policyrep/mls.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/mls.hpp
@@ -21,7 +21,7 @@ namespace policyrep
Sensitivity(const std::string& name);
Sensitivity(const Sensitivity& other);
virtual ~Sensitivity();
- virtual void operator=(const Sensitivity& other);
+ virtual Sensitivity& operator=(const Sensitivity& other);
template<class T>
Sensitivity(const std::string& name, T begin, T end)
@@ -50,7 +50,7 @@ namespace policyrep
Dominance();
Dominance(const Dominance& other);
virtual ~Dominance();
- virtual void operator=(const Dominance& other);
+ virtual Dominance& operator=(const Dominance& other);
template<class T>
Dominance(T begin, T end)
@@ -79,7 +79,7 @@ namespace policyrep
Category(const std::string& name);
Category(const Category& other);
virtual ~Category();
- virtual void operator=(const Category& other);
+ virtual Category& operator=(const Category& other);
template<class T>
Category(const std::string& name, T begin, T end)
@@ -109,7 +109,7 @@ namespace policyrep
Level(const std::string& name);
Level(const Level& other);
virtual ~Level();
- virtual void operator=(const Level& other);
+ virtual Level& operator=(const Level& other);
template<class T>
Level(const std::string& name, T begin, T end)
@@ -145,7 +145,7 @@ namespace policyrep
virtual const LevelPtr& get_high() const;
virtual LevelPtr& get_low();
virtual LevelPtr& get_high();
- virtual void operator=(const Range& other);
+ virtual Range& operator=(const Range& other);
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
protected:
void init();
--- policyrep.new.orig/libpolicyrep/include/policyrep/object_class.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/object_class.hpp
@@ -20,7 +20,7 @@ namespace policyrep
CommonPerms();
CommonPerms(const CommonPerms& other);
virtual ~CommonPerms();
- virtual void operator=(const CommonPerms& other);
+ virtual CommonPerms& operator=(const CommonPerms& other);
template<class T>
CommonPerms(const std::string& name, T perms_begin, T perms_end)
@@ -53,7 +53,7 @@ namespace policyrep
ObjectClass(const std::string& name, const std::string& commons);
ObjectClass(const ObjectClass& other);
virtual ~ObjectClass();
- virtual void operator=(const ObjectClass& other);
+ virtual ObjectClass& operator=(const ObjectClass& other);
template<class T>
ObjectClass(std::string name, std::string commons,
--- policyrep.new.orig/libpolicyrep/include/policyrep/optional.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/optional.hpp
@@ -19,7 +19,7 @@ namespace policyrep
OptionalBlock(OptionalBranchPtr true_);
OptionalBlock(OptionalBranchPtr true_, OptionalBranchPtr false_);
virtual ~OptionalBlock();
- virtual void operator=(const OptionalBlock& other);
+ virtual OptionalBlock& operator=(const OptionalBlock& other);
protected:
void copy(const OptionalBlock& other);
OptionalBlockImpl* impl;
@@ -33,7 +33,7 @@ namespace policyrep
OptionalBranch();
OptionalBranch(const OptionalBranch& other);
virtual ~OptionalBranch();
- virtual void operator=(const OptionalBranch& other);
+ virtual OptionalBranch& operator=(const OptionalBranch& other);
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
--- policyrep.new.orig/libpolicyrep/include/policyrep/parse.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/parse.hpp
@@ -18,7 +18,7 @@ namespace policyrep {
Parser();
Parser(const Parser& other);
virtual ~Parser();
- virtual void operator=(const Parser& other);
+ virtual Parser& operator=(const Parser& other);
// Parser
virtual ModulePtr parse(const std::string& f);
--- policyrep.new.orig/libpolicyrep/include/policyrep/policy.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/policy.hpp
@@ -28,7 +28,7 @@ namespace policyrep
Policy(bool mls=false);
Policy(const Policy& other);
virtual ~Policy();
- virtual void operator=(const Policy& other);
+ virtual Policy& operator=(const Policy& other);
virtual bool get_mls() const;
virtual void set_mls(bool val);
@@ -50,7 +50,7 @@ namespace policyrep
Module(const std::string& name, const std::string& version);
Module(const Module& other);
virtual ~Module();
- virtual void operator=(const Module& other);
+ virtual Module& operator=(const Module& other);
virtual const std::string& get_name() const;
virtual void set_name(const std::string& name);
@@ -77,7 +77,7 @@ namespace policyrep
InitialSid(const std::string& name);
InitialSid(const InitialSid& other);
virtual ~InitialSid();
- virtual void operator=(const InitialSid& other);
+ virtual InitialSid& operator=(const InitialSid& other);
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
--- policyrep.new.orig/libpolicyrep/include/policyrep/policy_base.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/policy_base.hpp
@@ -82,7 +82,7 @@ namespace policyrep {
OutputFormatter();
OutputFormatter(const OutputFormatter& other);
~OutputFormatter();
- void operator=(const OutputFormatter& other);
+ OutputFormatter& operator=(const OutputFormatter& other);
OutputFormatter& operator()(const Node& n, bool end=false);
OutputFormatter& operator()(NodePtr n, bool end=false);
@@ -117,7 +117,7 @@ namespace policyrep {
Node();
Node(const Node& other);
virtual ~Node();
- virtual void operator=(const Node& other);
+ virtual Node& operator=(const Node& other);
virtual void set_parent(Parent* p);
virtual Parent* get_parent() const;
@@ -153,7 +153,7 @@ namespace policyrep {
explicit TreeIterator(Parent* n, enum Strategy strategy=POSTORDER);
TreeIterator(const TreeIterator& other);
virtual ~TreeIterator();
- void operator=(const TreeIterator& other);
+ TreeIterator& operator=(const TreeIterator& other);
bool get_visited() const;
private:
friend class boost::iterator_core_access;
@@ -177,7 +177,7 @@ namespace policyrep {
Parent();
Parent(const Parent& other);
virtual ~Parent();
- virtual void operator=(const Parent& other);
+ virtual Parent& operator=(const Parent& other);
typedef TreeIterator iterator;
virtual void append_child(NodePtr Node);
@@ -223,7 +223,7 @@ namespace policyrep {
PolicyBlock(PolicyBranchPtr true_, PolicyBranchPtr false_);
PolicyBlock(const PolicyBlock& other);
virtual ~PolicyBlock();
- virtual void operator=(const PolicyBlock& other);
+ virtual PolicyBlock& operator=(const PolicyBlock& other);
virtual void append_child(PolicyBranchPtr node);
@@ -250,7 +250,7 @@ namespace policyrep {
PolicyBranch();
PolicyBranch(const PolicyBranch& other);
virtual ~PolicyBranch();
- virtual void operator=(const PolicyBranch& other);
+ virtual PolicyBranch& operator=(const PolicyBranch& other);
virtual void set_isfalse(bool v);
virtual bool get_isfalse() const;
--- policyrep.new.orig/libpolicyrep/include/policyrep/rbac.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/rbac.hpp
@@ -21,7 +21,7 @@ namespace policyrep
Role(const std::string& name);
Role(const Role& other);
virtual ~Role();
- virtual void operator=(const Role& other);
+ virtual Role& operator=(const Role& other);
template<class T>
Role(const std::string& name, T types_begin, T end)
--- policyrep.new.orig/libpolicyrep/include/policyrep/rule.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/rule.hpp
@@ -21,7 +21,7 @@ namespace policyrep
AVRule(Type type=ALLOW);
AVRule(const AVRule& other);
virtual ~AVRule();
- virtual void operator=(const AVRule& other);
+ virtual AVRule& operator=(const AVRule& other);
virtual void set_type(Type type);
virtual Type get_type() const;
@@ -50,7 +50,7 @@ namespace policyrep
TypeRule(Type type=TRANSITION);
TypeRule(const TypeRule& other);
virtual ~TypeRule();
- virtual void operator=(const TypeRule& other);
+ virtual TypeRule& operator=(const TypeRule& other);
virtual void set_type(Type type);
virtual Type get_type() const;
--- policyrep.new.orig/libpolicyrep/include/policyrep/te_decl.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/te_decl.hpp
@@ -21,7 +21,7 @@ namespace policyrep
Type(const std::string& name);
Type(const Type& other);
virtual ~Type();
- virtual void operator=(const Type& other);
+ virtual Type& operator=(const Type& other);
template<class T>
Type(const std::string& name, T attrs_begin, T end)
@@ -63,7 +63,7 @@ namespace policyrep
Attribute(const std::string& name);
Attribute(const Attribute& other);
virtual ~Attribute();
- virtual void operator=(const Attribute& other);
+ virtual Attribute& operator=(const Attribute& other);
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
@@ -83,7 +83,7 @@ namespace policyrep
TypeAttribute();
TypeAttribute(const TypeAttribute& other);
virtual ~TypeAttribute();
- virtual void operator=(const TypeAttribute& other);
+ virtual TypeAttribute& operator=(const TypeAttribute& other);
template<class T>
TypeAttribute(const std::string& name, T attrs_begin,
@@ -116,7 +116,7 @@ namespace policyrep
TypeAlias();
TypeAlias(const TypeAlias& other);
virtual ~TypeAlias();
- virtual void operator=(const TypeAlias& other);
+ virtual TypeAlias& operator=(const TypeAlias& other);
template<class T>
TypeAlias(const std::string& name, T attrs_begin,
--- policyrep.new.orig/libpolicyrep/include/policyrep/user.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/user.hpp
@@ -22,7 +22,7 @@ namespace policyrep
User(const std::string& name);
User(const User& other);
virtual ~User();
- virtual void operator=(const User& other);
+ virtual User& operator=(const User& other);
template<class T>
User(const std::string& name, T roles_begin, T end)
--- policyrep.new.orig/libpolicyrep/src/idset.cpp
+++ policyrep.new/libpolicyrep/src/idset.cpp
@@ -45,9 +45,10 @@ namespace policyrep
IdSet::~IdSet() { delete impl; }
- void IdSet::operator=(const IdSet& other)
+ IdSet& IdSet::operator=(const IdSet& other)
{
*impl = *other.impl;
+ return *this;
}
void IdSet::set_compl(bool val)
--- policyrep.new.orig/libpolicyrep/src/policy.cpp
+++ policyrep.new/libpolicyrep/src/policy.cpp
@@ -47,9 +47,11 @@ namespace policyrep
Policy::~Policy() { delete impl; }
- void Policy::operator=(const Policy& other)
+ Policy& Policy::operator=(const Policy& other)
{
- copy(other);
+ Parent::operator=(other);
+ *impl = *other.impl;
+ return *this;
}
bool Policy::get_mls() const
@@ -98,9 +100,11 @@ namespace policyrep
Module::~Module() { delete impl; }
- void Module::operator=(const Module& other)
+ Module& Module::operator=(const Module& other)
{
- copy(other);
+ Parent::operator=(other);
+ *impl = *other.impl;
+ return *this;
}
const std::string& Module::get_name() const
@@ -166,9 +170,11 @@ namespace policyrep
InitialSid::~InitialSid() { delete impl; }
- void InitialSid::operator=(const InitialSid& other)
+ InitialSid& InitialSid::operator=(const InitialSid& other)
{
- copy(other);
+ Symbol::operator=(other);
+ *impl = *other.impl;
+ return *this;
}
void InitialSid::do_output(std::ostream& o, const OutputFormatter& op) const
--- policyrep.new.orig/libpolicyrep/src/conditional.cpp
+++ policyrep.new/libpolicyrep/src/conditional.cpp
@@ -57,10 +57,11 @@ namespace policyrep
delete impl;
}
- void CondBool::operator=(const CondBool& other)
+ CondBool& CondBool::operator=(const CondBool& other)
{
Symbol::operator=(other);
- copy(other);
+ *impl = *other.impl;
+ return *this;
}
void CondBool::set_default_value(bool v)
@@ -125,9 +126,10 @@ namespace policyrep
delete impl;
}
- void CondOp::operator=(const CondOp& other)
+ CondOp& CondOp::operator=(const CondOp& other)
{
*impl = *other.impl;
+ return *this;
}
void CondOp::set_bool(const std::string& b)
@@ -212,9 +214,11 @@ namespace policyrep
delete impl;
}
- void CondBlock::operator=(const CondBlock& other)
+ CondBlock& CondBlock::operator=(const CondBlock& other)
{
- copy(other);
+ PolicyBlock::operator=(other);
+ *impl = *other.impl;
+ return *this;
}
void CondBlock::copy(const CondBlock& other)
@@ -248,9 +252,11 @@ namespace policyrep
delete impl;
}
- void CondBranch::operator=(const CondBranch& other)
+ CondBranch& CondBranch::operator=(const CondBranch& other)
{
- copy(other);
+ PolicyBranch::operator=(other);
+ *impl = *other.impl;
+ return *this;
}
CondExpr& CondBranch::expr()
--- policyrep.new.orig/libpolicyrep/src/mls.cpp
+++ policyrep.new/libpolicyrep/src/mls.cpp
@@ -104,9 +104,10 @@ namespace policyrep
Dominance::~Dominance() { delete impl; }
- void Dominance::operator=(const Dominance& other)
+ Dominance& Dominance::operator=(const Dominance& other)
{
*impl = *other.impl;
+ return *this;
}
StringVector& Dominance::ordering()
@@ -159,9 +160,10 @@ namespace policyrep
Category::~Category() { delete impl; }
- void Category::operator=(const Category& other)
+ Category& Category::operator=(const Category& other)
{
*impl = *other.impl;
+ return *this;
}
StringSet& Category::aliases()
@@ -218,9 +220,10 @@ namespace policyrep
delete impl;
}
- void Level::operator=(const Level& other)
+ Level& Level::operator=(const Level& other)
{
*impl = *other.impl;
+ return *this;
}
StringSet& Level::categories()
@@ -285,9 +288,10 @@ namespace policyrep
delete impl;
}
- void Range::operator=(const Range& other)
+ Range& Range::operator=(const Range& other)
{
*impl = *(other.impl);
+ return *this;
}
const LevelPtr& Range::get_low(void) const
--- policyrep.new.orig/libpolicyrep/src/object_class.cpp
+++ policyrep.new/libpolicyrep/src/object_class.cpp
@@ -47,9 +47,10 @@ namespace policyrep {
delete impl;
}
- void CommonPerms::operator=(const CommonPerms& other)
+ CommonPerms& CommonPerms::operator=(const CommonPerms& other)
{
- copy(other);
+ *impl = *other.impl;
+ return *this;
}
StringSet& CommonPerms::perms()
@@ -108,9 +109,10 @@ namespace policyrep {
delete impl;
}
- void ObjectClass::operator=(const ObjectClass& other)
+ ObjectClass& ObjectClass::operator=(const ObjectClass& other)
{
- copy(other);
+ *impl = *other.impl;
+ return *this;
}
StringSet& ObjectClass::perms()
--- policyrep.new.orig/libpolicyrep/src/optional.cpp
+++ policyrep.new/libpolicyrep/src/optional.cpp
@@ -52,9 +52,11 @@ namespace policyrep
delete impl;
}
- void OptionalBlock::operator=(const OptionalBlock& other)
+ OptionalBlock& OptionalBlock::operator=(const OptionalBlock& other)
{
- copy(other);
+ PolicyBlock::operator=(other);
+ *impl = *other.impl;
+ return *this;
}
void OptionalBlock::copy(const OptionalBlock& other)
@@ -81,9 +83,11 @@ namespace policyrep
delete impl;
}
- void OptionalBranch::operator=(const OptionalBranch& other)
+ OptionalBranch& OptionalBranch::operator=(const OptionalBranch& other)
{
- copy(other);
+ PolicyBranch::operator=(other);
+ *impl = *other.impl;
+ return *this;
}
void OptionalBranch::do_output(std::ostream& o, const OutputFormatter& op) const
--- policyrep.new.orig/libpolicyrep/src/parse.cpp
+++ policyrep.new/libpolicyrep/src/parse.cpp
@@ -46,9 +46,10 @@ namespace policyrep {
Parser::~Parser() { delete impl; }
- void Parser::operator=(const Parser& other)
+ Parser& Parser::operator=(const Parser& other)
{
*impl = *other.impl;
+ return *this;
}
ModulePtr Parser::parse(const std::string& f)
--- policyrep.new.orig/libpolicyrep/src/policy_base.cpp
+++ policyrep.new/libpolicyrep/src/policy_base.cpp
@@ -99,9 +99,10 @@ namespace policyrep
delete impl;
}
- void OutputFormatter::operator=(const OutputFormatter& other)
+ OutputFormatter& OutputFormatter::operator=(const OutputFormatter& other)
{
*impl = *other.impl;
+ return *this;
}
OutputFormatter& OutputFormatter::operator()(const Node& n, bool end)
@@ -207,10 +208,11 @@ namespace policyrep
delete node_impl;
}
- void Node::operator=(const Node& other)
+ Node& Node::operator=(const Node& other)
{
std::cout << "node" << std::endl;
- copy(other);
+ *node_impl = *other.node_impl;
+ return *this;
}
void Node::set_parent(Parent* parent)
@@ -342,9 +344,10 @@ namespace policyrep
delete impl;
}
- void TreeIterator::operator=(const TreeIterator& other)
+ TreeIterator& TreeIterator::operator=(const TreeIterator& other)
{
*impl = *other.impl;
+ return *this;
}
bool TreeIterator::get_visited() const
@@ -448,9 +451,11 @@ namespace policyrep
delete parent_impl;
}
- void Parent::operator=(const Parent& other)
+ Parent& Parent::operator=(const Parent& other)
{
- copy(other);
+ Node::operator=(other);
+ *parent_impl = *other.parent_impl;
+ return *this;
}
void Parent::make_child(NodePtr node)
@@ -540,9 +545,11 @@ namespace policyrep
delete block_impl;
}
- void PolicyBlock::operator=(const PolicyBlock& other)
+ PolicyBlock& PolicyBlock::operator=(const PolicyBlock& other)
{
- copy(other);
+ Parent::operator=(other);
+ *block_impl = *other.block_impl;
+ return *this;
}
void PolicyBlock::append_child(PolicyBranchPtr node)
@@ -652,9 +659,11 @@ namespace policyrep
delete branch_impl;
}
- void PolicyBranch::operator=(const PolicyBranch& other)
+ PolicyBranch& PolicyBranch::operator=(const PolicyBranch& other)
{
- copy(other);
+ Parent::operator=(other);
+ *branch_impl = *other.branch_impl;
+ return *this;
}
void PolicyBranch::set_isfalse(bool v)
--- policyrep.new.orig/libpolicyrep/src/rbac.cpp
+++ policyrep.new/libpolicyrep/src/rbac.cpp
@@ -58,9 +58,11 @@ namespace policyrep
Role::~Role() { delete impl; }
- void Role::operator=(const Role& other)
+ Role& Role::operator=(const Role& other)
{
+ Symbol::operator=(other);
*impl = *other.impl;
+ return *this;
}
StringSet& Role::types()
--- policyrep.new.orig/libpolicyrep/src/rule.cpp
+++ policyrep.new/libpolicyrep/src/rule.cpp
@@ -59,9 +59,11 @@ namespace policyrep
delete impl;
}
- void AVRule::operator=(const AVRule& other)
+ AVRule& AVRule::operator=(const AVRule& other)
{
- copy(other);
+ Node::operator=(other);
+ *impl = *other.impl;
+ return *this;
}
void AVRule::set_type(AVRule::Type type)
@@ -170,9 +172,11 @@ namespace policyrep
delete impl;
}
- void TypeRule::operator=(const TypeRule& other)
+ TypeRule& TypeRule::operator=(const TypeRule& other)
{
- copy(other);
+ Node::operator=(other);
+ *impl = *other.impl;
+ return *this;
}
void TypeRule::set_type(TypeRule::Type type)
--- policyrep.new.orig/libpolicyrep/src/te_decl.cpp
+++ policyrep.new/libpolicyrep/src/te_decl.cpp
@@ -61,9 +61,11 @@ namespace policyrep
Type::~Type() { delete impl; }
- void Type::operator=(const Type& other)
+ Type& Type::operator=(const Type& other)
{
- copy(other);
+ Symbol::operator=(other);
+ *impl = *other.impl;
+ return *this;
}
StringSet& Type::aliases()
@@ -163,9 +165,10 @@ namespace policyrep
TypeAttribute::~TypeAttribute() { delete impl; }
- void TypeAttribute::operator=(const TypeAttribute& other)
+ TypeAttribute& TypeAttribute::operator=(const TypeAttribute& other)
{
- copy(other);
+ *impl = *other.impl;
+ return *this;
}
const std::string& TypeAttribute::get_name() const
@@ -224,9 +227,11 @@ namespace policyrep
delete impl;
}
- void TypeAlias::operator=(const TypeAlias& other)
+ TypeAlias& TypeAlias::operator=(const TypeAlias& other)
{
- copy(other);
+ Node::operator=(other);
+ *impl = *other.impl;
+ return *this;
}
const std::string& TypeAlias::get_name() const
--- policyrep.new.orig/libpolicyrep/src/user.cpp
+++ policyrep.new/libpolicyrep/src/user.cpp
@@ -63,9 +63,10 @@ namespace policyrep
delete impl;
}
- void User::operator=(const User& other)
+ User& User::operator=(const User& other)
{
*impl = *other.impl;
+ return *this;
}
StringSet& User::roles()
--
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [POLICYREP] [patch 6/7] add negset to idset
2008-01-22 19:43 [POLICYREP] [patch 0/7] various cleanups and base symbol class Joshua Brindle
` (4 preceding siblings ...)
2008-01-22 19:43 ` [POLICYREP] [patch 5/7] fix operator= calls to return pointer Joshua Brindle
@ 2008-01-22 19:43 ` Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 7/7] remove unused copy/init functions Joshua Brindle
6 siblings, 0 replies; 9+ messages in thread
From: Joshua Brindle @ 2008-01-22 19:43 UTC (permalink / raw)
To: selinux; +Cc: sds, kmacmillan, tmiller
Add negset to idset for use in av rules
---
libpolicyrep/include/policyrep/idset.hpp | 15 +++++++++++++++
libpolicyrep/src/idset.cpp | 6 ++++++
2 files changed, 21 insertions(+)
--- policyrep.new.orig/libpolicyrep/include/policyrep/idset.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/idset.hpp
@@ -6,6 +6,7 @@
#include <policyrep/policy_base.hpp>
#include <set>
+#include <algorithm>
namespace policyrep
{
@@ -15,6 +16,19 @@ namespace policyrep
public:
IdSet();
IdSet(const IdSet& other);
+ template<typename I>
+ IdSet(bool comp, I sids, I eids){
+ init();
+ set_compl(comp);
+ ids().insert(sids, eids);
+ }
+ template<typename I>
+ IdSet(bool comp, I sids, I eids, I snids, I enids){
+ init();
+ set_compl(comp);
+ ids().insert(sids, eids);
+ neg_ids().insert(snids, enids);
+ }
~IdSet();
IdSet& operator=(const IdSet& other);
@@ -22,6 +36,7 @@ namespace policyrep
bool get_compl() const;
StringSet& ids();
+ StringSet& neg_ids();
protected:
void init();
IdSetImpl* impl;
--- policyrep.new.orig/libpolicyrep/src/idset.cpp
+++ policyrep.new/libpolicyrep/src/idset.cpp
@@ -27,6 +27,7 @@ namespace policyrep
{
IdSetImpl() : compliment(false) { }
StringSet ids;
+ StringSet neg_ids;
bool compliment;
};
@@ -66,4 +67,9 @@ namespace policyrep
return impl->ids;
}
+ StringSet& IdSet::neg_ids()
+ {
+ return impl->neg_ids;
+ }
+
} // namespace policyre
--
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [POLICYREP] [patch 7/7] remove unused copy/init functions
2008-01-22 19:43 [POLICYREP] [patch 0/7] various cleanups and base symbol class Joshua Brindle
` (5 preceding siblings ...)
2008-01-22 19:43 ` [POLICYREP] [patch 6/7] add negset to idset Joshua Brindle
@ 2008-01-22 19:43 ` Joshua Brindle
2008-01-22 21:29 ` Joshua Brindle
6 siblings, 1 reply; 9+ messages in thread
From: Joshua Brindle @ 2008-01-22 19:43 UTC (permalink / raw)
To: selinux; +Cc: sds, kmacmillan, tmiller
This removes all copy/init functions because 1) they aren't used anymore and 2) they are dangerous to call as they blow away the old impl. The copy constructors are now used instead of copy()
---
libpolicyrep/include/policyrep/conditional.hpp | 2
libpolicyrep/include/policyrep/idset.hpp | 3
libpolicyrep/include/policyrep/mls.hpp | 13 ++-
libpolicyrep/include/policyrep/object_class.hpp | 9 +-
libpolicyrep/include/policyrep/optional.hpp | 2
libpolicyrep/include/policyrep/policy.hpp | 3
libpolicyrep/include/policyrep/policy_base.hpp | 4 -
libpolicyrep/include/policyrep/rbac.hpp | 3
libpolicyrep/include/policyrep/rule.hpp | 4 -
libpolicyrep/include/policyrep/te_decl.hpp | 14 +---
libpolicyrep/include/policyrep/user.hpp | 3
libpolicyrep/src/conditional.cpp | 30 +-------
libpolicyrep/src/idset.cpp | 7 +-
libpolicyrep/src/mls.cpp | 39 ++++++-----
libpolicyrep/src/object_class.cpp | 41 ++++++-----
libpolicyrep/src/optional.cpp | 20 +----
libpolicyrep/src/policy.cpp | 30 +-------
libpolicyrep/src/policy_base.cpp | 38 ++--------
libpolicyrep/src/policyrep_python.cpp | 84 ++++++++++++------------
libpolicyrep/src/rbac.cpp | 5 +
libpolicyrep/src/rule.cpp | 39 ++---------
libpolicyrep/src/te_decl.cpp | 71 +++++++++-----------
22 files changed, 180 insertions(+), 284 deletions(-)
--- policyrep.new.orig/libpolicyrep/include/policyrep/conditional.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/conditional.hpp
@@ -53,7 +53,6 @@ namespace policyrep
virtual void set_default_value(bool v);
virtual bool get_default_value() const;
protected:
- void copy(const CondBool& other);
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
CondBoolImpl* impl;
};
@@ -115,7 +114,6 @@ namespace policyrep
virtual ~CondBlock();
virtual CondBlock& operator=(const CondBlock& other);
protected:
- void copy(const CondBlock& other);
CondBlockImpl* impl;
};
--- policyrep.new.orig/libpolicyrep/include/policyrep/idset.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/idset.hpp
@@ -38,8 +38,9 @@ namespace policyrep
StringSet& ids();
StringSet& neg_ids();
protected:
- void init();
IdSetImpl* impl;
+ private:
+ void init();
};
--- policyrep.new.orig/libpolicyrep/include/policyrep/mls.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/mls.hpp
@@ -34,8 +34,9 @@ namespace policyrep
virtual StringSet& aliases();
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void init();
SensitivityImpl* impl;
+ private:
+ void init();
};
typedef boost::shared_ptr<Sensitivity> SensitivityPtr;
@@ -62,8 +63,9 @@ namespace policyrep
virtual StringVector& ordering();
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void init();
DominanceImpl* impl;
+ private:
+ void init();
};
typedef boost::shared_ptr<Dominance> DominancePtr;
@@ -91,8 +93,9 @@ namespace policyrep
virtual StringSet& aliases();
protected:
- virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
+ private:
void init();
+ virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
CategoryImpl* impl;
};
typedef boost::shared_ptr<Category> CategoryPtr;
@@ -123,8 +126,9 @@ namespace policyrep
virtual void do_output_brief(std::ostream& o, const OutputFormatter& op) const;
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void init();
LevelImpl* impl;
+ private:
+ void init();
};
typedef boost::shared_ptr<Level> LevelPtr;
@@ -148,7 +152,6 @@ namespace policyrep
virtual Range& operator=(const Range& other);
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
protected:
- void init();
RangeImpl* impl;
};
typedef boost::shared_ptr<Range> RangePtr;
--- policyrep.new.orig/libpolicyrep/include/policyrep/object_class.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/object_class.hpp
@@ -34,9 +34,9 @@ namespace policyrep
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void init();
- void copy(const CommonPerms& other);
CommonPermsImpl* impl;
+ private:
+ void init();
};
typedef boost::shared_ptr<CommonPerms> CommonPermsPtr;
@@ -71,13 +71,12 @@ namespace policyrep
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void init();
- void copy(const ObjectClass& other);
ObjectClassImpl* impl;
+ private:
+ void init();
};
typedef boost::shared_ptr<ObjectClass> ObjectClassPtr;
-
} // namespace policyrep
#endif
--- policyrep.new.orig/libpolicyrep/include/policyrep/optional.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/optional.hpp
@@ -21,7 +21,6 @@ namespace policyrep
virtual ~OptionalBlock();
virtual OptionalBlock& operator=(const OptionalBlock& other);
protected:
- void copy(const OptionalBlock& other);
OptionalBlockImpl* impl;
};
typedef boost::shared_ptr<OptionalBlock> OptionalBlockPtr;
@@ -37,7 +36,6 @@ namespace policyrep
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void copy(const OptionalBranch& other);
OptionalBranchImpl* impl;
};
--- policyrep.new.orig/libpolicyrep/include/policyrep/policy_base.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/policy_base.hpp
@@ -132,7 +132,6 @@ namespace policyrep {
protected:
virtual void output_indentation(std::ostream& o, const OutputFormatter& op) const;
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void copy(const Node& other);
NodeImpl* node_impl;
static const int VISITED = 1;
};
@@ -197,7 +196,6 @@ namespace policyrep {
virtual bool ignore_indent() const;
protected:
- void copy(const Parent& other);
ParentImpl* parent_impl;
};
typedef boost::shared_ptr<Parent> ParentPtr;
@@ -235,7 +233,6 @@ namespace policyrep {
virtual void set_false(PolicyBranchPtr branch);
virtual bool ignore_indent() const;
protected:
- void copy(const PolicyBlock& other);
PolicyBlockImpl* block_impl;
};
@@ -255,7 +252,6 @@ namespace policyrep {
virtual void set_isfalse(bool v);
virtual bool get_isfalse() const;
protected:
- void copy(const PolicyBranch& other);
PolicyBranchImpl* branch_impl;
};
--- policyrep.new.orig/libpolicyrep/include/policyrep/policy.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/policy.hpp
@@ -34,7 +34,6 @@ namespace policyrep
virtual void set_mls(bool val);
virtual bool ignore_indent() const;
protected:
- void copy(const Policy& other);
PolicyImpl* impl;
};
typedef boost::shared_ptr<Policy> PolicyPtr;
@@ -60,7 +59,6 @@ namespace policyrep
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void copy(const Module& other);
ModuleImpl* impl;
};
typedef boost::shared_ptr<Module> ModulePtr;
@@ -81,7 +79,6 @@ namespace policyrep
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void copy(const InitialSid& other);
InitialSidImpl* impl;
};
typedef boost::shared_ptr<InitialSid> InitialSidPtr;
--- policyrep.new.orig/libpolicyrep/include/policyrep/rbac.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/rbac.hpp
@@ -34,8 +34,9 @@ namespace policyrep
virtual StringSet& types();
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void init();
RoleImpl* impl;
+ private:
+ void init();
};
typedef boost::shared_ptr<Role> RolePtr;
--- policyrep.new.orig/libpolicyrep/include/policyrep/rule.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/rule.hpp
@@ -33,8 +33,6 @@ namespace policyrep
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void init();
- void copy(const AVRule& other);
AVRuleImpl* impl;
};
@@ -63,8 +61,6 @@ namespace policyrep
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void init();
- void copy(const TypeRule& other);
TypeRuleImpl* impl;
};
--- policyrep.new.orig/libpolicyrep/include/policyrep/te_decl.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/te_decl.hpp
@@ -45,9 +45,9 @@ namespace policyrep
virtual StringSet& attributes();
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void init();
- virtual void copy(const Type& other);
TypeImpl* impl;
+ private:
+ void init();
};
typedef boost::shared_ptr<Type> TypePtr;
@@ -67,7 +67,6 @@ namespace policyrep
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- virtual void copy(const Attribute& other);
AttributeImpl* impl;
};
typedef boost::shared_ptr<Attribute> AttributePtr;
@@ -99,9 +98,9 @@ namespace policyrep
virtual StringSet& attributes();
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void init();
- virtual void copy(const TypeAttribute& other);
TypeAttributeImpl* impl;
+ private:
+ void init();
};
typedef boost::shared_ptr<TypeAttribute> TypeAttributePtr;
@@ -132,13 +131,12 @@ namespace policyrep
virtual StringSet& aliases();
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void init();
- virtual void copy(const TypeAlias& other);
TypeAliasImpl* impl;
+ private:
+ void init();
};
typedef boost::shared_ptr<TypeAlias> TypeAliasPtr;
-
} // namespace policyrep
#endif
--- policyrep.new.orig/libpolicyrep/include/policyrep/user.hpp
+++ policyrep.new/libpolicyrep/include/policyrep/user.hpp
@@ -52,8 +52,9 @@ namespace policyrep
virtual StringSet& roles();
protected:
virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
- void init();
UserImpl* impl;
+ private:
+ void init();
};
typedef boost::shared_ptr<User> UserPtr;
--- policyrep.new.orig/libpolicyrep/src/conditional.cpp
+++ policyrep.new/libpolicyrep/src/conditional.cpp
@@ -49,7 +49,7 @@ namespace policyrep
CondBool::CondBool(const CondBool& other) : Symbol(other), impl(new CondBoolImpl)
{
- copy(other);
+ *impl = *other.impl;
}
CondBool::~CondBool()
@@ -83,12 +83,6 @@ namespace policyrep
o << "false;";
}
- void CondBool::copy(const CondBool& other)
- {
- Node::copy(other);
- *impl = *other.impl;
- }
-
//
// CondOp
//
@@ -181,7 +175,6 @@ namespace policyrep
return o;
}
-
//
// CondBlock
//
@@ -204,9 +197,9 @@ namespace policyrep
append_child(else_);
}
- CondBlock::CondBlock(const CondBlock& other) : PolicyBlock(), impl(new CondBlockImpl)
+ CondBlock::CondBlock(const CondBlock& other) : PolicyBlock(other), impl(new CondBlockImpl)
{
- copy(other);
+ *impl = *other.impl;
}
CondBlock::~CondBlock()
@@ -221,13 +214,6 @@ namespace policyrep
return *this;
}
- void CondBlock::copy(const CondBlock& other)
- {
- PolicyBlock::copy(other);
- *impl = *other.impl;
- }
-
-
//
// CondBranch
//
@@ -242,9 +228,9 @@ namespace policyrep
}
- CondBranch::CondBranch(const CondBranch& other) : PolicyBranch(), impl(new CondBranchImpl)
+ CondBranch::CondBranch(const CondBranch& other) : PolicyBranch(other), impl(new CondBranchImpl)
{
- copy(other);
+ *impl = *other.impl;
}
CondBranch::~CondBranch()
@@ -294,10 +280,4 @@ namespace policyrep
}
- void CondBranch::copy(const CondBranch& other)
- {
- PolicyBranch::copy(other);
- *impl = *other.impl;
- }
-
}
--- policyrep.new.orig/libpolicyrep/src/idset.cpp
+++ policyrep.new/libpolicyrep/src/idset.cpp
@@ -36,11 +36,14 @@ namespace policyrep
impl = new IdSetImpl;
}
- IdSet::IdSet() { init(); }
+ IdSet::IdSet()
+ {
+ impl = new IdSetImpl;
+ }
IdSet::IdSet(const IdSet& other)
{
- init();
+ impl = new IdSetImpl;
*impl = *other.impl;
}
--- policyrep.new.orig/libpolicyrep/src/mls.cpp
+++ policyrep.new/libpolicyrep/src/mls.cpp
@@ -56,11 +56,15 @@ namespace policyrep
*impl = *other.impl;
}
- Sensitivity::~Sensitivity() { delete impl; }
+ Sensitivity::~Sensitivity()
+ {
+ delete impl;
+ }
- void Sensitivity::operator=(const Sensitivity& other)
+ Sensitivity& Sensitivity::operator=(const Sensitivity& other)
{
*impl = *other.impl;
+ return *this;
}
StringSet& Sensitivity::aliases()
@@ -93,12 +97,16 @@ namespace policyrep
impl = new DominanceImpl;
}
- Dominance::Dominance() { init(); }
+ Dominance::Dominance()
+ :Node()
+ {
+ impl = new DominanceImpl;
+ }
Dominance::Dominance(const Dominance& other)
- : Node()
+ :Node(other)
{
- init();
+ impl = new DominanceImpl;
*impl = *other.impl;
}
@@ -158,7 +166,10 @@ namespace policyrep
*impl = *other.impl;
}
- Category::~Category() { delete impl; }
+ Category::~Category()
+ {
+ delete impl;
+ }
Category& Category::operator=(const Category& other)
{
@@ -260,26 +271,26 @@ namespace policyrep
Range::Range()
{
- init();
+ impl = new RangeImpl;
}
Range::Range(LevelPtr low)
{
- init();
+ impl = new RangeImpl;
impl->low = low;
}
Range::Range(LevelPtr low, LevelPtr high)
{
- init();
+ impl = new RangeImpl;
impl->low = low;
impl->high = high;
}
Range::Range(const Range& other)
- : Node()
+ :Node(other)
{
- init();
+ impl = new RangeImpl;
*impl = *(other.impl);
}
@@ -323,10 +334,4 @@ namespace policyrep
}
}
- void Range::init()
- {
- impl = new RangeImpl;
- }
-
-
} // namespace policyrep
--- policyrep.new.orig/libpolicyrep/src/object_class.cpp
+++ policyrep.new/libpolicyrep/src/object_class.cpp
@@ -31,9 +31,15 @@ namespace policyrep {
StringSet perms;
};
- void CommonPerms::init() { impl = new CommonPermsImpl; }
+ void CommonPerms::init()
+ {
+ impl = new CommonPermsImpl;
+ }
- CommonPerms::CommonPerms() { init(); }
+ CommonPerms::CommonPerms()
+ {
+ impl = new CommonPermsImpl;
+ }
CommonPerms::CommonPerms(const CommonPerms& other)
:Symbol(other)
@@ -49,6 +55,7 @@ namespace policyrep {
CommonPerms& CommonPerms::operator=(const CommonPerms& other)
{
+ Symbol::operator=(other);
*impl = *other.impl;
return *this;
}
@@ -64,12 +71,6 @@ namespace policyrep {
output_set_space(o, impl->perms);
}
- void CommonPerms::copy(const CommonPerms& other)
- {
- Node::copy(other);
- *impl = *other.impl;
- }
-
//
// ObjectClass
//
@@ -80,9 +81,15 @@ namespace policyrep {
std::string common_perms;
};
- void ObjectClass::init() { impl = new ObjectClassImpl; }
+ void ObjectClass::init()
+ {
+ impl = new ObjectClassImpl;
+ }
- ObjectClass::ObjectClass() { init(); }
+ ObjectClass::ObjectClass()
+ {
+ impl = new ObjectClassImpl;
+ }
ObjectClass::ObjectClass(const std::string &name)
:Symbol(name)
@@ -93,15 +100,15 @@ namespace policyrep {
ObjectClass::ObjectClass(const std::string& name, const std::string& commons)
:Symbol(name)
{
- init();
+ impl = new ObjectClassImpl;
set_common_perms(commons);
}
ObjectClass::ObjectClass(const ObjectClass& other)
:Symbol(other)
{
- init();
- copy(other);
+ impl = new ObjectClassImpl;
+ *impl = *other.impl;
}
ObjectClass::~ObjectClass()
@@ -111,6 +118,7 @@ namespace policyrep {
ObjectClass& ObjectClass::operator=(const ObjectClass& other)
{
+ Symbol::operator=(other);
*impl = *other.impl;
return *this;
}
@@ -141,11 +149,4 @@ namespace policyrep {
}
}
- void ObjectClass::copy(const ObjectClass& other)
- {
- Node::copy(other);
- *impl = *other.impl;
- }
-
-
} // namespace policyrep
--- policyrep.new.orig/libpolicyrep/src/optional.cpp
+++ policyrep.new/libpolicyrep/src/optional.cpp
@@ -30,9 +30,9 @@ namespace policyrep
}
- OptionalBlock::OptionalBlock(const OptionalBlock& other) : PolicyBlock()
+ OptionalBlock::OptionalBlock(const OptionalBlock& other) : PolicyBlock(other)
{
- copy(other);
+ *impl = *other.impl;
}
OptionalBlock::OptionalBlock(OptionalBranchPtr true_)
@@ -59,12 +59,6 @@ namespace policyrep
return *this;
}
- void OptionalBlock::copy(const OptionalBlock& other)
- {
- PolicyBlock::copy(other);
- *impl = *other.impl;
- }
-
struct OptionalBranchImpl { };
OptionalBranch::OptionalBranch() : impl(new OptionalBranchImpl)
@@ -73,9 +67,9 @@ namespace policyrep
}
OptionalBranch::OptionalBranch(const OptionalBranch& other)
- : PolicyBranch(), impl(new OptionalBranchImpl)
+ : PolicyBranch(other), impl(new OptionalBranchImpl)
{
- copy(other);
+ *impl = *other.impl;
}
OptionalBranch::~OptionalBranch()
@@ -103,10 +97,4 @@ namespace policyrep
}
}
- void OptionalBranch::copy(const OptionalBranch& other)
- {
- PolicyBranch::copy(other);
- }
-
-
}
--- policyrep.new.orig/libpolicyrep/src/policy_base.cpp
+++ policyrep.new/libpolicyrep/src/policy_base.cpp
@@ -200,7 +200,7 @@ namespace policyrep
Node::Node(const Node& other)
: node_impl(new NodeImpl)
{
- copy(other);
+ *node_impl = *other.node_impl;
}
Node::~Node()
@@ -292,11 +292,6 @@ namespace policyrep
}
}
- void Node::copy(const Node& other)
- {
- *node_impl = *other.node_impl;
- }
-
//
// TreeIterator
//
@@ -440,10 +435,10 @@ namespace policyrep
: parent_impl(new ParentImpl) { }
Parent::Parent(const Parent& other)
- : Node()
+ :Node(other)
{
parent_impl = new ParentImpl;
- copy(other);
+ *parent_impl = *other.parent_impl;
}
Parent::~Parent()
@@ -507,12 +502,6 @@ namespace policyrep
}
- void Parent::copy(const Parent& other)
- {
- Node::copy(other);
- *parent_impl = *other.parent_impl;
- }
-
//
// PolicyBlock
//
@@ -535,9 +524,9 @@ namespace policyrep
append_child(false_);
}
- PolicyBlock::PolicyBlock(const PolicyBlock& other) : Parent(), block_impl(new PolicyBlockImpl)
+ PolicyBlock::PolicyBlock(const PolicyBlock& other) : Parent(other), block_impl(new PolicyBlockImpl)
{
- copy(other);
+ *block_impl = *other.block_impl;
}
PolicyBlock::~PolicyBlock()
@@ -628,12 +617,6 @@ namespace policyrep
return true;
}
- void PolicyBlock::copy(const PolicyBlock& other)
- {
- Parent::copy(other);
- *block_impl = *other.block_impl;
- }
-
//
// PolicyBranch
@@ -649,9 +632,9 @@ namespace policyrep
}
- PolicyBranch::PolicyBranch(const PolicyBranch& other) : Parent(), branch_impl(new PolicyBranchImpl)
+ PolicyBranch::PolicyBranch(const PolicyBranch& other) : Parent(other), branch_impl(new PolicyBranchImpl)
{
- copy(other);
+ *branch_impl = *other.branch_impl;
}
PolicyBranch::~PolicyBranch()
@@ -676,11 +659,4 @@ namespace policyrep
return branch_impl->isfalse;
}
- void PolicyBranch::copy(const PolicyBranch& other)
- {
- Parent::copy(other);
- *branch_impl = *other.branch_impl;
- }
-
-
} // namespace policyrep
--- policyrep.new.orig/libpolicyrep/src/policy.cpp
+++ policyrep.new/libpolicyrep/src/policy.cpp
@@ -40,9 +40,9 @@ namespace policyrep
: impl(new PolicyImpl(mls)) { }
Policy::Policy(const Policy& other)
- : Parent(), impl(new PolicyImpl)
+ : Parent(other), impl(new PolicyImpl)
{
- copy(other);
+ *impl = *other.impl;
}
Policy::~Policy() { delete impl; }
@@ -69,12 +69,6 @@ namespace policyrep
return true;
}
- void Policy::copy(const Policy& other)
- {
- Parent::copy(other);
- *impl = *other.impl;
- }
-
//
// Module
//
@@ -93,9 +87,9 @@ namespace policyrep
: impl(new ModuleImpl(name, version)) { }
Module::Module(const Module& other)
- : Parent(), impl(new ModuleImpl)
+ : Parent(other), impl(new ModuleImpl)
{
- copy(other);
+ *impl = *other.impl;
}
Module::~Module() { delete impl; }
@@ -139,13 +133,6 @@ namespace policyrep
return true;
}
- void Module::copy(const Module& other)
- {
- Parent::copy(other);
- *impl = *other.impl;
- }
-
-
//
// InitialSid
//
@@ -165,7 +152,7 @@ namespace policyrep
InitialSid::InitialSid(const InitialSid& other)
: Symbol(other), impl(new InitialSidImpl)
{
- copy(other);
+ *impl = *other.impl;
}
InitialSid::~InitialSid() { delete impl; }
@@ -182,11 +169,4 @@ namespace policyrep
o << "sid " << get_name();
}
- void InitialSid::copy(const InitialSid& other)
- {
- Node::copy(other);
- *impl = *other.impl;
- }
-
-
} // namespace Policyrep
--- policyrep.new.orig/libpolicyrep/src/policyrep_python.cpp
+++ policyrep.new/libpolicyrep/src/policyrep_python.cpp
@@ -58,10 +58,10 @@ BOOST_PYTHON_MODULE(policyrep)
//
class_<Node>("Node")
- .add_property("parent",
- make_function(&Node::get_parent,
- return_value_policy<reference_existing_object>()),
- &Node::set_parent)
+// .add_property("parent",
+// make_function(&Node::get_parent,
+// return_value_policy<reference_existing_object>()),
+// &Node::set_parent)
.add_property("visited", &Node::get_visited, &Node::set_visited)
.def("__str__", &Node::to_string)
.def("to_string_end", &Node::to_string_end)
@@ -99,20 +99,20 @@ BOOST_PYTHON_MODULE(policyrep)
class_<Module, bases<Parent> >("Module")
- .add_property("name",
- make_function(&Module::get_name,
- return_value_policy<copy_const_reference>()),
- &Module::set_name)
- .add_property("version", make_function(&Module::get_version,
- return_value_policy<copy_const_reference>()),
- &Module::set_version)
+// .add_property("name",
+// make_function(&Module::get_name,
+// return_value_policy<copy_const_reference>()),
+// &Module::set_name)
+// .add_property("version", make_function(&Module::get_version,
+// return_value_policy<copy_const_reference>()),
+// &Module::set_version)
;
register_ptr_to_python<ModulePtr>();
class_<InitialSid, bases<Node> >("InitialSid")
- .add_property("name", make_function(&InitialSid::get_name,
- return_value_policy<reference_existing_object>()),
- &InitialSid::set_name)
+// .add_property("name", make_function(&InitialSid::get_name,
+// return_value_policy<reference_existing_object>()),
+// &InitialSid::set_name)
;
register_ptr_to_python<InitialSidPtr>();
@@ -121,10 +121,10 @@ BOOST_PYTHON_MODULE(policyrep)
//
class_<Type, bases<Node> >("Type")
- .add_property("name",
- make_function(&Type::get_name,
- return_value_policy<copy_const_reference>()),
- &Type::set_name)
+// .add_property("name",
+// make_function(&Type::get_name,
+// return_value_policy<copy_const_reference>()),
+// &Type::set_name)
.add_property("aliases"
, make_function(
&Type::aliases,
@@ -139,18 +139,18 @@ BOOST_PYTHON_MODULE(policyrep)
register_ptr_to_python<TypePtr>();
class_<Attribute, bases<Node> >("Attribute")
- .add_property("name",
- make_function(&Attribute::get_name,
- return_value_policy<copy_const_reference>()),
- &Attribute::set_name)
+// .add_property("name",
+// make_function(&Attribute::get_name,
+// return_value_policy<copy_const_reference>()),
+// &Attribute::set_name)
;
register_ptr_to_python<AttributePtr>();
class_<TypeAttribute, bases<Node> >("TypeAttribute")
- .add_property("name",
- make_function(&TypeAttribute::get_name,
- return_value_policy<copy_const_reference>()),
- &TypeAttribute::set_name)
+// .add_property("name",
+// make_function(&TypeAttribute::get_name,
+// return_value_policy<copy_const_reference>()),
+// &TypeAttribute::set_name)
.add_property("attributes",
make_function(&TypeAttribute::attributes,
return_value_policy<reference_existing_object>()))
@@ -158,10 +158,10 @@ BOOST_PYTHON_MODULE(policyrep)
register_ptr_to_python<TypeAttributePtr>();
class_<TypeAlias, bases<Node> >("TypeAlias")
- .add_property("name",
- make_function(&TypeAlias::get_name,
- return_value_policy<copy_const_reference>()),
- &TypeAlias::set_name)
+// .add_property("name",
+// make_function(&TypeAlias::get_name,
+// return_value_policy<copy_const_reference>()),
+// &TypeAlias::set_name)
.add_property("aliases",
make_function(&TypeAlias::aliases,
return_value_policy<reference_existing_object>()))
@@ -176,10 +176,10 @@ BOOST_PYTHON_MODULE(policyrep)
//
class_<CommonPerms, bases<Node> >("CommonPerms")
- .add_property("name",
- make_function(&CommonPerms::get_name,
- return_value_policy<copy_const_reference>()),
- &CommonPerms::set_name)
+// .add_property("name",
+// make_function(&CommonPerms::get_name,
+// return_value_policy<copy_const_reference>()),
+// &CommonPerms::set_name)
.add_property("perms",
make_function(&CommonPerms::perms,
return_value_policy<reference_existing_object>()))
@@ -187,14 +187,14 @@ BOOST_PYTHON_MODULE(policyrep)
register_ptr_to_python<CommonPermsPtr>();
class_<ObjectClass, bases<Node> >("ObjectClass")
- .add_property("name",
- make_function(&ObjectClass::get_name,
- return_value_policy<copy_const_reference>()),
- &ObjectClass::set_name)
- .add_property("common_perms",
- make_function(&ObjectClass::get_common_perms,
- return_value_policy<copy_const_reference>()),
- &ObjectClass::set_common_perms)
+// .add_property("name",
+// make_function(&ObjectClass::get_name,
+// return_value_policy<copy_const_reference>()),
+// &ObjectClass::set_name)
+// .add_property("common_perms",
+// make_function(&ObjectClass::get_common_perms,
+// return_value_policy<copy_const_reference>()),
+// &ObjectClass::set_common_perms)
.add_property("perms",
make_function(&ObjectClass::perms,
return_value_policy<reference_existing_object>()))
--- policyrep.new.orig/libpolicyrep/src/rbac.cpp
+++ policyrep.new/libpolicyrep/src/rbac.cpp
@@ -56,7 +56,10 @@ namespace policyrep
*impl = *other.impl;
}
- Role::~Role() { delete impl; }
+ Role::~Role()
+ {
+ delete impl;
+ }
Role& Role::operator=(const Role& other)
{
--- policyrep.new.orig/libpolicyrep/src/rule.cpp
+++ policyrep.new/libpolicyrep/src/rule.cpp
@@ -36,22 +36,17 @@ namespace policyrep
IdSet perms;
};
- void AVRule::init()
- {
- impl = new AVRuleImpl;
- }
-
AVRule::AVRule(Type type)
{
- init();
+ impl = new AVRuleImpl;
impl->type = type;
}
AVRule::AVRule(const AVRule& other)
- : Node()
+ :Node(other)
{
- init();
- copy(other);
+ impl = new AVRuleImpl;
+ *impl = *other.impl;
}
AVRule::~AVRule()
@@ -130,12 +125,6 @@ namespace policyrep
}
- void AVRule::copy(const AVRule& other)
- {
- Node::copy(other);
- *impl = *other.impl;
- }
-
//
// TypeRule
//
@@ -149,22 +138,17 @@ namespace policyrep
std::string target;
};
- void TypeRule::init()
- {
- impl = new TypeRuleImpl;
- }
-
TypeRule::TypeRule(Type type)
{
- init();
+ impl = new TypeRuleImpl;
impl->type = type;
}
TypeRule::TypeRule(const TypeRule& other)
- : Node()
+ :Node(other)
{
- init();
- copy(other);
+ impl = new TypeRuleImpl;
+ *impl = *other.impl;
}
TypeRule::~TypeRule()
@@ -241,11 +225,4 @@ namespace policyrep
}
- void TypeRule::copy(const TypeRule& other)
- {
- Node::copy(other);
- *impl = *other.impl;
- }
-
-
} // namespace policyrep
--- policyrep.new.orig/libpolicyrep/src/te_decl.cpp
+++ policyrep.new/libpolicyrep/src/te_decl.cpp
@@ -59,7 +59,10 @@ namespace policyrep
*impl = *other.impl;
}
- Type::~Type() { delete impl; }
+ Type::~Type()
+ {
+ delete impl;
+ }
Type& Type::operator=(const Type& other)
{
@@ -92,12 +95,6 @@ namespace policyrep
o << ";";
}
- void Type::copy(const Type& other)
- {
- Node::copy(other);
- *impl = *other.impl;
- }
-
//
// Attribute
//
@@ -124,12 +121,14 @@ namespace policyrep
Attribute::Attribute(const Attribute& other)
:Symbol(other), impl(new AttributeImpl)
{
- copy(other);
+ *impl = *other.impl;
}
- void Attribute::operator=(const Attribute& other)
+ Attribute& Attribute::operator=(const Attribute& other)
{
- copy(other);
+ Symbol::operator=(other);
+ *impl = *other.impl;
+ return *this;
}
void Attribute::do_output(std::ostream& o, const OutputFormatter& op) const
@@ -137,12 +136,6 @@ namespace policyrep
o << "attribute " << get_name() << ";";
}
- void Attribute::copy(const Attribute& other)
- {
- Node::copy(other);
- *impl = *other.impl;
- }
-
//
// TypeAttribute
//
@@ -153,20 +146,31 @@ namespace policyrep
StringSet attributes;
};
- void TypeAttribute::init() { impl = new TypeAttributeImpl; }
+ void TypeAttribute::init()
+ {
+ impl = new TypeAttributeImpl;
+ }
- TypeAttribute::TypeAttribute() { init(); }
+ TypeAttribute::TypeAttribute()
+ {
+ impl = new TypeAttributeImpl;
+ }
TypeAttribute::TypeAttribute(const TypeAttribute& other)
- : Node()
+ :Node(other)
{
- copy(other);
+ impl = new TypeAttributeImpl;
+ *impl = *other.impl;
}
- TypeAttribute::~TypeAttribute() { delete impl; }
+ TypeAttribute::~TypeAttribute()
+ {
+ delete impl;
+ }
TypeAttribute& TypeAttribute::operator=(const TypeAttribute& other)
{
+ Node::operator=(other);
*impl = *other.impl;
return *this;
}
@@ -193,12 +197,6 @@ namespace policyrep
o << ";";
}
- void TypeAttribute::copy(const TypeAttribute& other)
- {
- Node::copy(other);
- *impl = *other.impl;
- }
-
//
// TypeAlias
//
@@ -209,17 +207,21 @@ namespace policyrep
StringSet aliases;
};
- void TypeAlias::init() { impl = new TypeAliasImpl; }
+ void TypeAlias::init()
+ {
+ impl = new TypeAliasImpl;
+ }
TypeAlias::TypeAlias()
{
- init();
+ impl = new TypeAliasImpl;
}
TypeAlias::TypeAlias(const TypeAlias& other)
- : Node()
+ :Node(other)
{
- copy(other);
+ impl = new TypeAliasImpl;
+ *impl = *other.impl;
}
TypeAlias::~TypeAlias()
@@ -256,11 +258,4 @@ namespace policyrep
o << ";";
}
- void TypeAlias::copy(const TypeAlias& other)
- {
- Node::copy(other);
- *impl = *other.impl;
- }
-
-
} // namespace policyrep
--
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [POLICYREP] [patch 7/7] remove unused copy/init functions
2008-01-22 19:43 ` [POLICYREP] [patch 7/7] remove unused copy/init functions Joshua Brindle
@ 2008-01-22 21:29 ` Joshua Brindle
0 siblings, 0 replies; 9+ messages in thread
From: Joshua Brindle @ 2008-01-22 21:29 UTC (permalink / raw)
To: selinux; +Cc: sds, kmacmillan, tmiller
Joshua Brindle wrote:
> This removes all copy/init functions because 1) they aren't used anymore and 2) they are dangerous to call as they blow away the old impl. The copy constructors are now used instead of copy()
>
Oops, this patch also commented out (temporarily) some of the python
bindings that aren't quite working and some other misc cleanups. Sorry
about that.
> ---
> libpolicyrep/include/policyrep/conditional.hpp | 2
> libpolicyrep/include/policyrep/idset.hpp | 3
> libpolicyrep/include/policyrep/mls.hpp | 13 ++-
> libpolicyrep/include/policyrep/object_class.hpp | 9 +-
> libpolicyrep/include/policyrep/optional.hpp | 2
> libpolicyrep/include/policyrep/policy.hpp | 3
> libpolicyrep/include/policyrep/policy_base.hpp | 4 -
> libpolicyrep/include/policyrep/rbac.hpp | 3
> libpolicyrep/include/policyrep/rule.hpp | 4 -
> libpolicyrep/include/policyrep/te_decl.hpp | 14 +---
> libpolicyrep/include/policyrep/user.hpp | 3
> libpolicyrep/src/conditional.cpp | 30 +-------
> libpolicyrep/src/idset.cpp | 7 +-
> libpolicyrep/src/mls.cpp | 39 ++++++-----
> libpolicyrep/src/object_class.cpp | 41 ++++++-----
> libpolicyrep/src/optional.cpp | 20 +----
> libpolicyrep/src/policy.cpp | 30 +-------
> libpolicyrep/src/policy_base.cpp | 38 ++--------
> libpolicyrep/src/policyrep_python.cpp | 84 ++++++++++++------------
> libpolicyrep/src/rbac.cpp | 5 +
> libpolicyrep/src/rule.cpp | 39 ++---------
> libpolicyrep/src/te_decl.cpp | 71 +++++++++-----------
> 22 files changed, 180 insertions(+), 284 deletions(-)
>
> --- policyrep.new.orig/libpolicyrep/include/policyrep/conditional.hpp
> +++ policyrep.new/libpolicyrep/include/policyrep/conditional.hpp
> @@ -53,7 +53,6 @@ namespace policyrep
> virtual void set_default_value(bool v);
> virtual bool get_default_value() const;
> protected:
> - void copy(const CondBool& other);
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> CondBoolImpl* impl;
> };
> @@ -115,7 +114,6 @@ namespace policyrep
> virtual ~CondBlock();
> virtual CondBlock& operator=(const CondBlock& other);
> protected:
> - void copy(const CondBlock& other);
> CondBlockImpl* impl;
> };
>
> --- policyrep.new.orig/libpolicyrep/include/policyrep/idset.hpp
> +++ policyrep.new/libpolicyrep/include/policyrep/idset.hpp
> @@ -38,8 +38,9 @@ namespace policyrep
> StringSet& ids();
> StringSet& neg_ids();
> protected:
> - void init();
> IdSetImpl* impl;
> + private:
> + void init();
> };
>
>
> --- policyrep.new.orig/libpolicyrep/include/policyrep/mls.hpp
> +++ policyrep.new/libpolicyrep/include/policyrep/mls.hpp
> @@ -34,8 +34,9 @@ namespace policyrep
> virtual StringSet& aliases();
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void init();
> SensitivityImpl* impl;
> + private:
> + void init();
> };
> typedef boost::shared_ptr<Sensitivity> SensitivityPtr;
>
> @@ -62,8 +63,9 @@ namespace policyrep
> virtual StringVector& ordering();
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void init();
> DominanceImpl* impl;
> + private:
> + void init();
> };
> typedef boost::shared_ptr<Dominance> DominancePtr;
>
> @@ -91,8 +93,9 @@ namespace policyrep
>
> virtual StringSet& aliases();
> protected:
> - virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> + private:
> void init();
> + virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> CategoryImpl* impl;
> };
> typedef boost::shared_ptr<Category> CategoryPtr;
> @@ -123,8 +126,9 @@ namespace policyrep
> virtual void do_output_brief(std::ostream& o, const OutputFormatter& op) const;
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void init();
> LevelImpl* impl;
> + private:
> + void init();
> };
> typedef boost::shared_ptr<Level> LevelPtr;
>
> @@ -148,7 +152,6 @@ namespace policyrep
> virtual Range& operator=(const Range& other);
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> protected:
> - void init();
> RangeImpl* impl;
> };
> typedef boost::shared_ptr<Range> RangePtr;
> --- policyrep.new.orig/libpolicyrep/include/policyrep/object_class.hpp
> +++ policyrep.new/libpolicyrep/include/policyrep/object_class.hpp
> @@ -34,9 +34,9 @@ namespace policyrep
>
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void init();
> - void copy(const CommonPerms& other);
> CommonPermsImpl* impl;
> + private:
> + void init();
> };
> typedef boost::shared_ptr<CommonPerms> CommonPermsPtr;
>
> @@ -71,13 +71,12 @@ namespace policyrep
>
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void init();
> - void copy(const ObjectClass& other);
> ObjectClassImpl* impl;
> + private:
> + void init();
> };
> typedef boost::shared_ptr<ObjectClass> ObjectClassPtr;
>
> -
> } // namespace policyrep
>
> #endif
> --- policyrep.new.orig/libpolicyrep/include/policyrep/optional.hpp
> +++ policyrep.new/libpolicyrep/include/policyrep/optional.hpp
> @@ -21,7 +21,6 @@ namespace policyrep
> virtual ~OptionalBlock();
> virtual OptionalBlock& operator=(const OptionalBlock& other);
> protected:
> - void copy(const OptionalBlock& other);
> OptionalBlockImpl* impl;
> };
> typedef boost::shared_ptr<OptionalBlock> OptionalBlockPtr;
> @@ -37,7 +36,6 @@ namespace policyrep
>
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void copy(const OptionalBranch& other);
> OptionalBranchImpl* impl;
> };
>
> --- policyrep.new.orig/libpolicyrep/include/policyrep/policy_base.hpp
> +++ policyrep.new/libpolicyrep/include/policyrep/policy_base.hpp
> @@ -132,7 +132,6 @@ namespace policyrep {
> protected:
> virtual void output_indentation(std::ostream& o, const OutputFormatter& op) const;
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void copy(const Node& other);
> NodeImpl* node_impl;
> static const int VISITED = 1;
> };
> @@ -197,7 +196,6 @@ namespace policyrep {
>
> virtual bool ignore_indent() const;
> protected:
> - void copy(const Parent& other);
> ParentImpl* parent_impl;
> };
> typedef boost::shared_ptr<Parent> ParentPtr;
> @@ -235,7 +233,6 @@ namespace policyrep {
> virtual void set_false(PolicyBranchPtr branch);
> virtual bool ignore_indent() const;
> protected:
> - void copy(const PolicyBlock& other);
> PolicyBlockImpl* block_impl;
> };
>
> @@ -255,7 +252,6 @@ namespace policyrep {
> virtual void set_isfalse(bool v);
> virtual bool get_isfalse() const;
> protected:
> - void copy(const PolicyBranch& other);
> PolicyBranchImpl* branch_impl;
> };
>
> --- policyrep.new.orig/libpolicyrep/include/policyrep/policy.hpp
> +++ policyrep.new/libpolicyrep/include/policyrep/policy.hpp
> @@ -34,7 +34,6 @@ namespace policyrep
> virtual void set_mls(bool val);
> virtual bool ignore_indent() const;
> protected:
> - void copy(const Policy& other);
> PolicyImpl* impl;
> };
> typedef boost::shared_ptr<Policy> PolicyPtr;
> @@ -60,7 +59,6 @@ namespace policyrep
>
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void copy(const Module& other);
> ModuleImpl* impl;
> };
> typedef boost::shared_ptr<Module> ModulePtr;
> @@ -81,7 +79,6 @@ namespace policyrep
>
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void copy(const InitialSid& other);
> InitialSidImpl* impl;
> };
> typedef boost::shared_ptr<InitialSid> InitialSidPtr;
> --- policyrep.new.orig/libpolicyrep/include/policyrep/rbac.hpp
> +++ policyrep.new/libpolicyrep/include/policyrep/rbac.hpp
> @@ -34,8 +34,9 @@ namespace policyrep
> virtual StringSet& types();
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void init();
> RoleImpl* impl;
> + private:
> + void init();
> };
> typedef boost::shared_ptr<Role> RolePtr;
>
> --- policyrep.new.orig/libpolicyrep/include/policyrep/rule.hpp
> +++ policyrep.new/libpolicyrep/include/policyrep/rule.hpp
> @@ -33,8 +33,6 @@ namespace policyrep
>
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void init();
> - void copy(const AVRule& other);
> AVRuleImpl* impl;
> };
>
> @@ -63,8 +61,6 @@ namespace policyrep
>
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void init();
> - void copy(const TypeRule& other);
> TypeRuleImpl* impl;
> };
>
> --- policyrep.new.orig/libpolicyrep/include/policyrep/te_decl.hpp
> +++ policyrep.new/libpolicyrep/include/policyrep/te_decl.hpp
> @@ -45,9 +45,9 @@ namespace policyrep
> virtual StringSet& attributes();
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void init();
> - virtual void copy(const Type& other);
> TypeImpl* impl;
> + private:
> + void init();
> };
> typedef boost::shared_ptr<Type> TypePtr;
>
> @@ -67,7 +67,6 @@ namespace policyrep
>
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - virtual void copy(const Attribute& other);
> AttributeImpl* impl;
> };
> typedef boost::shared_ptr<Attribute> AttributePtr;
> @@ -99,9 +98,9 @@ namespace policyrep
> virtual StringSet& attributes();
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void init();
> - virtual void copy(const TypeAttribute& other);
> TypeAttributeImpl* impl;
> + private:
> + void init();
> };
> typedef boost::shared_ptr<TypeAttribute> TypeAttributePtr;
>
> @@ -132,13 +131,12 @@ namespace policyrep
> virtual StringSet& aliases();
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void init();
> - virtual void copy(const TypeAlias& other);
> TypeAliasImpl* impl;
> + private:
> + void init();
> };
> typedef boost::shared_ptr<TypeAlias> TypeAliasPtr;
>
> -
> } // namespace policyrep
>
> #endif
> --- policyrep.new.orig/libpolicyrep/include/policyrep/user.hpp
> +++ policyrep.new/libpolicyrep/include/policyrep/user.hpp
> @@ -52,8 +52,9 @@ namespace policyrep
> virtual StringSet& roles();
> protected:
> virtual void do_output(std::ostream& o, const OutputFormatter& op) const;
> - void init();
> UserImpl* impl;
> + private:
> + void init();
> };
> typedef boost::shared_ptr<User> UserPtr;
>
> --- policyrep.new.orig/libpolicyrep/src/conditional.cpp
> +++ policyrep.new/libpolicyrep/src/conditional.cpp
> @@ -49,7 +49,7 @@ namespace policyrep
>
> CondBool::CondBool(const CondBool& other) : Symbol(other), impl(new CondBoolImpl)
> {
> - copy(other);
> + *impl = *other.impl;
> }
>
> CondBool::~CondBool()
> @@ -83,12 +83,6 @@ namespace policyrep
> o << "false;";
> }
>
> - void CondBool::copy(const CondBool& other)
> - {
> - Node::copy(other);
> - *impl = *other.impl;
> - }
> -
> //
> // CondOp
> //
> @@ -181,7 +175,6 @@ namespace policyrep
> return o;
> }
>
> -
> //
> // CondBlock
> //
> @@ -204,9 +197,9 @@ namespace policyrep
> append_child(else_);
> }
>
> - CondBlock::CondBlock(const CondBlock& other) : PolicyBlock(), impl(new CondBlockImpl)
> + CondBlock::CondBlock(const CondBlock& other) : PolicyBlock(other), impl(new CondBlockImpl)
> {
> - copy(other);
> + *impl = *other.impl;
> }
>
> CondBlock::~CondBlock()
> @@ -221,13 +214,6 @@ namespace policyrep
> return *this;
> }
>
> - void CondBlock::copy(const CondBlock& other)
> - {
> - PolicyBlock::copy(other);
> - *impl = *other.impl;
> - }
> -
> -
> //
> // CondBranch
> //
> @@ -242,9 +228,9 @@ namespace policyrep
>
> }
>
> - CondBranch::CondBranch(const CondBranch& other) : PolicyBranch(), impl(new CondBranchImpl)
> + CondBranch::CondBranch(const CondBranch& other) : PolicyBranch(other), impl(new CondBranchImpl)
> {
> - copy(other);
> + *impl = *other.impl;
> }
>
> CondBranch::~CondBranch()
> @@ -294,10 +280,4 @@ namespace policyrep
>
> }
>
> - void CondBranch::copy(const CondBranch& other)
> - {
> - PolicyBranch::copy(other);
> - *impl = *other.impl;
> - }
> -
> }
> --- policyrep.new.orig/libpolicyrep/src/idset.cpp
> +++ policyrep.new/libpolicyrep/src/idset.cpp
> @@ -36,11 +36,14 @@ namespace policyrep
> impl = new IdSetImpl;
> }
>
> - IdSet::IdSet() { init(); }
> + IdSet::IdSet()
> + {
> + impl = new IdSetImpl;
> + }
>
> IdSet::IdSet(const IdSet& other)
> {
> - init();
> + impl = new IdSetImpl;
> *impl = *other.impl;
> }
>
> --- policyrep.new.orig/libpolicyrep/src/mls.cpp
> +++ policyrep.new/libpolicyrep/src/mls.cpp
> @@ -56,11 +56,15 @@ namespace policyrep
> *impl = *other.impl;
> }
>
> - Sensitivity::~Sensitivity() { delete impl; }
> + Sensitivity::~Sensitivity()
> + {
> + delete impl;
> + }
>
> - void Sensitivity::operator=(const Sensitivity& other)
> + Sensitivity& Sensitivity::operator=(const Sensitivity& other)
> {
> *impl = *other.impl;
> + return *this;
> }
>
> StringSet& Sensitivity::aliases()
> @@ -93,12 +97,16 @@ namespace policyrep
> impl = new DominanceImpl;
> }
>
> - Dominance::Dominance() { init(); }
> + Dominance::Dominance()
> + :Node()
> + {
> + impl = new DominanceImpl;
> + }
>
> Dominance::Dominance(const Dominance& other)
> - : Node()
> + :Node(other)
> {
> - init();
> + impl = new DominanceImpl;
> *impl = *other.impl;
> }
>
> @@ -158,7 +166,10 @@ namespace policyrep
> *impl = *other.impl;
> }
>
> - Category::~Category() { delete impl; }
> + Category::~Category()
> + {
> + delete impl;
> + }
>
> Category& Category::operator=(const Category& other)
> {
> @@ -260,26 +271,26 @@ namespace policyrep
>
> Range::Range()
> {
> - init();
> + impl = new RangeImpl;
> }
>
> Range::Range(LevelPtr low)
> {
> - init();
> + impl = new RangeImpl;
> impl->low = low;
> }
>
> Range::Range(LevelPtr low, LevelPtr high)
> {
> - init();
> + impl = new RangeImpl;
> impl->low = low;
> impl->high = high;
> }
>
> Range::Range(const Range& other)
> - : Node()
> + :Node(other)
> {
> - init();
> + impl = new RangeImpl;
> *impl = *(other.impl);
> }
>
> @@ -323,10 +334,4 @@ namespace policyrep
> }
> }
>
> - void Range::init()
> - {
> - impl = new RangeImpl;
> - }
> -
> -
> } // namespace policyrep
> --- policyrep.new.orig/libpolicyrep/src/object_class.cpp
> +++ policyrep.new/libpolicyrep/src/object_class.cpp
> @@ -31,9 +31,15 @@ namespace policyrep {
> StringSet perms;
> };
>
> - void CommonPerms::init() { impl = new CommonPermsImpl; }
> + void CommonPerms::init()
> + {
> + impl = new CommonPermsImpl;
> + }
>
> - CommonPerms::CommonPerms() { init(); }
> + CommonPerms::CommonPerms()
> + {
> + impl = new CommonPermsImpl;
> + }
>
> CommonPerms::CommonPerms(const CommonPerms& other)
> :Symbol(other)
> @@ -49,6 +55,7 @@ namespace policyrep {
>
> CommonPerms& CommonPerms::operator=(const CommonPerms& other)
> {
> + Symbol::operator=(other);
> *impl = *other.impl;
> return *this;
> }
> @@ -64,12 +71,6 @@ namespace policyrep {
> output_set_space(o, impl->perms);
> }
>
> - void CommonPerms::copy(const CommonPerms& other)
> - {
> - Node::copy(other);
> - *impl = *other.impl;
> - }
> -
> //
> // ObjectClass
> //
> @@ -80,9 +81,15 @@ namespace policyrep {
> std::string common_perms;
> };
>
> - void ObjectClass::init() { impl = new ObjectClassImpl; }
> + void ObjectClass::init()
> + {
> + impl = new ObjectClassImpl;
> + }
>
> - ObjectClass::ObjectClass() { init(); }
> + ObjectClass::ObjectClass()
> + {
> + impl = new ObjectClassImpl;
> + }
>
> ObjectClass::ObjectClass(const std::string &name)
> :Symbol(name)
> @@ -93,15 +100,15 @@ namespace policyrep {
> ObjectClass::ObjectClass(const std::string& name, const std::string& commons)
> :Symbol(name)
> {
> - init();
> + impl = new ObjectClassImpl;
> set_common_perms(commons);
> }
>
> ObjectClass::ObjectClass(const ObjectClass& other)
> :Symbol(other)
> {
> - init();
> - copy(other);
> + impl = new ObjectClassImpl;
> + *impl = *other.impl;
> }
>
> ObjectClass::~ObjectClass()
> @@ -111,6 +118,7 @@ namespace policyrep {
>
> ObjectClass& ObjectClass::operator=(const ObjectClass& other)
> {
> + Symbol::operator=(other);
> *impl = *other.impl;
> return *this;
> }
> @@ -141,11 +149,4 @@ namespace policyrep {
> }
> }
>
> - void ObjectClass::copy(const ObjectClass& other)
> - {
> - Node::copy(other);
> - *impl = *other.impl;
> - }
> -
> -
> } // namespace policyrep
> --- policyrep.new.orig/libpolicyrep/src/optional.cpp
> +++ policyrep.new/libpolicyrep/src/optional.cpp
> @@ -30,9 +30,9 @@ namespace policyrep
>
> }
>
> - OptionalBlock::OptionalBlock(const OptionalBlock& other) : PolicyBlock()
> + OptionalBlock::OptionalBlock(const OptionalBlock& other) : PolicyBlock(other)
> {
> - copy(other);
> + *impl = *other.impl;
> }
>
> OptionalBlock::OptionalBlock(OptionalBranchPtr true_)
> @@ -59,12 +59,6 @@ namespace policyrep
> return *this;
> }
>
> - void OptionalBlock::copy(const OptionalBlock& other)
> - {
> - PolicyBlock::copy(other);
> - *impl = *other.impl;
> - }
> -
> struct OptionalBranchImpl { };
>
> OptionalBranch::OptionalBranch() : impl(new OptionalBranchImpl)
> @@ -73,9 +67,9 @@ namespace policyrep
> }
>
> OptionalBranch::OptionalBranch(const OptionalBranch& other)
> - : PolicyBranch(), impl(new OptionalBranchImpl)
> + : PolicyBranch(other), impl(new OptionalBranchImpl)
> {
> - copy(other);
> + *impl = *other.impl;
> }
>
> OptionalBranch::~OptionalBranch()
> @@ -103,10 +97,4 @@ namespace policyrep
> }
> }
>
> - void OptionalBranch::copy(const OptionalBranch& other)
> - {
> - PolicyBranch::copy(other);
> - }
> -
> -
> }
> --- policyrep.new.orig/libpolicyrep/src/policy_base.cpp
> +++ policyrep.new/libpolicyrep/src/policy_base.cpp
> @@ -200,7 +200,7 @@ namespace policyrep
> Node::Node(const Node& other)
> : node_impl(new NodeImpl)
> {
> - copy(other);
> + *node_impl = *other.node_impl;
> }
>
> Node::~Node()
> @@ -292,11 +292,6 @@ namespace policyrep
> }
> }
>
> - void Node::copy(const Node& other)
> - {
> - *node_impl = *other.node_impl;
> - }
> -
> //
> // TreeIterator
> //
> @@ -440,10 +435,10 @@ namespace policyrep
> : parent_impl(new ParentImpl) { }
>
> Parent::Parent(const Parent& other)
> - : Node()
> + :Node(other)
> {
> parent_impl = new ParentImpl;
> - copy(other);
> + *parent_impl = *other.parent_impl;
> }
>
> Parent::~Parent()
> @@ -507,12 +502,6 @@ namespace policyrep
>
> }
>
> - void Parent::copy(const Parent& other)
> - {
> - Node::copy(other);
> - *parent_impl = *other.parent_impl;
> - }
> -
> //
> // PolicyBlock
> //
> @@ -535,9 +524,9 @@ namespace policyrep
> append_child(false_);
> }
>
> - PolicyBlock::PolicyBlock(const PolicyBlock& other) : Parent(), block_impl(new PolicyBlockImpl)
> + PolicyBlock::PolicyBlock(const PolicyBlock& other) : Parent(other), block_impl(new PolicyBlockImpl)
> {
> - copy(other);
> + *block_impl = *other.block_impl;
> }
>
> PolicyBlock::~PolicyBlock()
> @@ -628,12 +617,6 @@ namespace policyrep
> return true;
> }
>
> - void PolicyBlock::copy(const PolicyBlock& other)
> - {
> - Parent::copy(other);
> - *block_impl = *other.block_impl;
> - }
> -
>
> //
> // PolicyBranch
> @@ -649,9 +632,9 @@ namespace policyrep
>
> }
>
> - PolicyBranch::PolicyBranch(const PolicyBranch& other) : Parent(), branch_impl(new PolicyBranchImpl)
> + PolicyBranch::PolicyBranch(const PolicyBranch& other) : Parent(other), branch_impl(new PolicyBranchImpl)
> {
> - copy(other);
> + *branch_impl = *other.branch_impl;
> }
>
> PolicyBranch::~PolicyBranch()
> @@ -676,11 +659,4 @@ namespace policyrep
> return branch_impl->isfalse;
> }
>
> - void PolicyBranch::copy(const PolicyBranch& other)
> - {
> - Parent::copy(other);
> - *branch_impl = *other.branch_impl;
> - }
> -
> -
> } // namespace policyrep
> --- policyrep.new.orig/libpolicyrep/src/policy.cpp
> +++ policyrep.new/libpolicyrep/src/policy.cpp
> @@ -40,9 +40,9 @@ namespace policyrep
> : impl(new PolicyImpl(mls)) { }
>
> Policy::Policy(const Policy& other)
> - : Parent(), impl(new PolicyImpl)
> + : Parent(other), impl(new PolicyImpl)
> {
> - copy(other);
> + *impl = *other.impl;
> }
>
> Policy::~Policy() { delete impl; }
> @@ -69,12 +69,6 @@ namespace policyrep
> return true;
> }
>
> - void Policy::copy(const Policy& other)
> - {
> - Parent::copy(other);
> - *impl = *other.impl;
> - }
> -
> //
> // Module
> //
> @@ -93,9 +87,9 @@ namespace policyrep
> : impl(new ModuleImpl(name, version)) { }
>
> Module::Module(const Module& other)
> - : Parent(), impl(new ModuleImpl)
> + : Parent(other), impl(new ModuleImpl)
> {
> - copy(other);
> + *impl = *other.impl;
> }
>
> Module::~Module() { delete impl; }
> @@ -139,13 +133,6 @@ namespace policyrep
> return true;
> }
>
> - void Module::copy(const Module& other)
> - {
> - Parent::copy(other);
> - *impl = *other.impl;
> - }
> -
> -
> //
> // InitialSid
> //
> @@ -165,7 +152,7 @@ namespace policyrep
> InitialSid::InitialSid(const InitialSid& other)
> : Symbol(other), impl(new InitialSidImpl)
> {
> - copy(other);
> + *impl = *other.impl;
> }
>
> InitialSid::~InitialSid() { delete impl; }
> @@ -182,11 +169,4 @@ namespace policyrep
> o << "sid " << get_name();
> }
>
> - void InitialSid::copy(const InitialSid& other)
> - {
> - Node::copy(other);
> - *impl = *other.impl;
> - }
> -
> -
> } // namespace Policyrep
> --- policyrep.new.orig/libpolicyrep/src/policyrep_python.cpp
> +++ policyrep.new/libpolicyrep/src/policyrep_python.cpp
> @@ -58,10 +58,10 @@ BOOST_PYTHON_MODULE(policyrep)
> //
>
> class_<Node>("Node")
> - .add_property("parent",
> - make_function(&Node::get_parent,
> - return_value_policy<reference_existing_object>()),
> - &Node::set_parent)
> +// .add_property("parent",
> +// make_function(&Node::get_parent,
> +// return_value_policy<reference_existing_object>()),
> +// &Node::set_parent)
> .add_property("visited", &Node::get_visited, &Node::set_visited)
> .def("__str__", &Node::to_string)
> .def("to_string_end", &Node::to_string_end)
> @@ -99,20 +99,20 @@ BOOST_PYTHON_MODULE(policyrep)
>
>
> class_<Module, bases<Parent> >("Module")
> - .add_property("name",
> - make_function(&Module::get_name,
> - return_value_policy<copy_const_reference>()),
> - &Module::set_name)
> - .add_property("version", make_function(&Module::get_version,
> - return_value_policy<copy_const_reference>()),
> - &Module::set_version)
> +// .add_property("name",
> +// make_function(&Module::get_name,
> +// return_value_policy<copy_const_reference>()),
> +// &Module::set_name)
> +// .add_property("version", make_function(&Module::get_version,
> +// return_value_policy<copy_const_reference>()),
> +// &Module::set_version)
> ;
> register_ptr_to_python<ModulePtr>();
>
> class_<InitialSid, bases<Node> >("InitialSid")
> - .add_property("name", make_function(&InitialSid::get_name,
> - return_value_policy<reference_existing_object>()),
> - &InitialSid::set_name)
> +// .add_property("name", make_function(&InitialSid::get_name,
> +// return_value_policy<reference_existing_object>()),
> +// &InitialSid::set_name)
> ;
> register_ptr_to_python<InitialSidPtr>();
>
> @@ -121,10 +121,10 @@ BOOST_PYTHON_MODULE(policyrep)
> //
>
> class_<Type, bases<Node> >("Type")
> - .add_property("name",
> - make_function(&Type::get_name,
> - return_value_policy<copy_const_reference>()),
> - &Type::set_name)
> +// .add_property("name",
> +// make_function(&Type::get_name,
> +// return_value_policy<copy_const_reference>()),
> +// &Type::set_name)
> .add_property("aliases"
> , make_function(
> &Type::aliases,
> @@ -139,18 +139,18 @@ BOOST_PYTHON_MODULE(policyrep)
> register_ptr_to_python<TypePtr>();
>
> class_<Attribute, bases<Node> >("Attribute")
> - .add_property("name",
> - make_function(&Attribute::get_name,
> - return_value_policy<copy_const_reference>()),
> - &Attribute::set_name)
> +// .add_property("name",
> +// make_function(&Attribute::get_name,
> +// return_value_policy<copy_const_reference>()),
> +// &Attribute::set_name)
> ;
> register_ptr_to_python<AttributePtr>();
>
> class_<TypeAttribute, bases<Node> >("TypeAttribute")
> - .add_property("name",
> - make_function(&TypeAttribute::get_name,
> - return_value_policy<copy_const_reference>()),
> - &TypeAttribute::set_name)
> +// .add_property("name",
> +// make_function(&TypeAttribute::get_name,
> +// return_value_policy<copy_const_reference>()),
> +// &TypeAttribute::set_name)
> .add_property("attributes",
> make_function(&TypeAttribute::attributes,
> return_value_policy<reference_existing_object>()))
> @@ -158,10 +158,10 @@ BOOST_PYTHON_MODULE(policyrep)
> register_ptr_to_python<TypeAttributePtr>();
>
> class_<TypeAlias, bases<Node> >("TypeAlias")
> - .add_property("name",
> - make_function(&TypeAlias::get_name,
> - return_value_policy<copy_const_reference>()),
> - &TypeAlias::set_name)
> +// .add_property("name",
> +// make_function(&TypeAlias::get_name,
> +// return_value_policy<copy_const_reference>()),
> +// &TypeAlias::set_name)
> .add_property("aliases",
> make_function(&TypeAlias::aliases,
> return_value_policy<reference_existing_object>()))
> @@ -176,10 +176,10 @@ BOOST_PYTHON_MODULE(policyrep)
> //
>
> class_<CommonPerms, bases<Node> >("CommonPerms")
> - .add_property("name",
> - make_function(&CommonPerms::get_name,
> - return_value_policy<copy_const_reference>()),
> - &CommonPerms::set_name)
> +// .add_property("name",
> +// make_function(&CommonPerms::get_name,
> +// return_value_policy<copy_const_reference>()),
> +// &CommonPerms::set_name)
> .add_property("perms",
> make_function(&CommonPerms::perms,
> return_value_policy<reference_existing_object>()))
> @@ -187,14 +187,14 @@ BOOST_PYTHON_MODULE(policyrep)
> register_ptr_to_python<CommonPermsPtr>();
>
> class_<ObjectClass, bases<Node> >("ObjectClass")
> - .add_property("name",
> - make_function(&ObjectClass::get_name,
> - return_value_policy<copy_const_reference>()),
> - &ObjectClass::set_name)
> - .add_property("common_perms",
> - make_function(&ObjectClass::get_common_perms,
> - return_value_policy<copy_const_reference>()),
> - &ObjectClass::set_common_perms)
> +// .add_property("name",
> +// make_function(&ObjectClass::get_name,
> +// return_value_policy<copy_const_reference>()),
> +// &ObjectClass::set_name)
> +// .add_property("common_perms",
> +// make_function(&ObjectClass::get_common_perms,
> +// return_value_policy<copy_const_reference>()),
> +// &ObjectClass::set_common_perms)
> .add_property("perms",
> make_function(&ObjectClass::perms,
> return_value_policy<reference_existing_object>()))
> --- policyrep.new.orig/libpolicyrep/src/rbac.cpp
> +++ policyrep.new/libpolicyrep/src/rbac.cpp
> @@ -56,7 +56,10 @@ namespace policyrep
> *impl = *other.impl;
> }
>
> - Role::~Role() { delete impl; }
> + Role::~Role()
> + {
> + delete impl;
> + }
>
> Role& Role::operator=(const Role& other)
> {
> --- policyrep.new.orig/libpolicyrep/src/rule.cpp
> +++ policyrep.new/libpolicyrep/src/rule.cpp
> @@ -36,22 +36,17 @@ namespace policyrep
> IdSet perms;
> };
>
> - void AVRule::init()
> - {
> - impl = new AVRuleImpl;
> - }
> -
> AVRule::AVRule(Type type)
> {
> - init();
> + impl = new AVRuleImpl;
> impl->type = type;
> }
>
> AVRule::AVRule(const AVRule& other)
> - : Node()
> + :Node(other)
> {
> - init();
> - copy(other);
> + impl = new AVRuleImpl;
> + *impl = *other.impl;
> }
>
> AVRule::~AVRule()
> @@ -130,12 +125,6 @@ namespace policyrep
>
> }
>
> - void AVRule::copy(const AVRule& other)
> - {
> - Node::copy(other);
> - *impl = *other.impl;
> - }
> -
> //
> // TypeRule
> //
> @@ -149,22 +138,17 @@ namespace policyrep
> std::string target;
> };
>
> - void TypeRule::init()
> - {
> - impl = new TypeRuleImpl;
> - }
> -
> TypeRule::TypeRule(Type type)
> {
> - init();
> + impl = new TypeRuleImpl;
> impl->type = type;
> }
>
> TypeRule::TypeRule(const TypeRule& other)
> - : Node()
> + :Node(other)
> {
> - init();
> - copy(other);
> + impl = new TypeRuleImpl;
> + *impl = *other.impl;
> }
>
> TypeRule::~TypeRule()
> @@ -241,11 +225,4 @@ namespace policyrep
>
> }
>
> - void TypeRule::copy(const TypeRule& other)
> - {
> - Node::copy(other);
> - *impl = *other.impl;
> - }
> -
> -
> } // namespace policyrep
> --- policyrep.new.orig/libpolicyrep/src/te_decl.cpp
> +++ policyrep.new/libpolicyrep/src/te_decl.cpp
> @@ -59,7 +59,10 @@ namespace policyrep
> *impl = *other.impl;
> }
>
> - Type::~Type() { delete impl; }
> + Type::~Type()
> + {
> + delete impl;
> + }
>
> Type& Type::operator=(const Type& other)
> {
> @@ -92,12 +95,6 @@ namespace policyrep
> o << ";";
> }
>
> - void Type::copy(const Type& other)
> - {
> - Node::copy(other);
> - *impl = *other.impl;
> - }
> -
> //
> // Attribute
> //
> @@ -124,12 +121,14 @@ namespace policyrep
> Attribute::Attribute(const Attribute& other)
> :Symbol(other), impl(new AttributeImpl)
> {
> - copy(other);
> + *impl = *other.impl;
> }
>
> - void Attribute::operator=(const Attribute& other)
> + Attribute& Attribute::operator=(const Attribute& other)
> {
> - copy(other);
> + Symbol::operator=(other);
> + *impl = *other.impl;
> + return *this;
> }
>
> void Attribute::do_output(std::ostream& o, const OutputFormatter& op) const
> @@ -137,12 +136,6 @@ namespace policyrep
> o << "attribute " << get_name() << ";";
> }
>
> - void Attribute::copy(const Attribute& other)
> - {
> - Node::copy(other);
> - *impl = *other.impl;
> - }
> -
> //
> // TypeAttribute
> //
> @@ -153,20 +146,31 @@ namespace policyrep
> StringSet attributes;
> };
>
> - void TypeAttribute::init() { impl = new TypeAttributeImpl; }
> + void TypeAttribute::init()
> + {
> + impl = new TypeAttributeImpl;
> + }
>
> - TypeAttribute::TypeAttribute() { init(); }
> + TypeAttribute::TypeAttribute()
> + {
> + impl = new TypeAttributeImpl;
> + }
>
> TypeAttribute::TypeAttribute(const TypeAttribute& other)
> - : Node()
> + :Node(other)
> {
> - copy(other);
> + impl = new TypeAttributeImpl;
> + *impl = *other.impl;
> }
>
> - TypeAttribute::~TypeAttribute() { delete impl; }
> + TypeAttribute::~TypeAttribute()
> + {
> + delete impl;
> + }
>
> TypeAttribute& TypeAttribute::operator=(const TypeAttribute& other)
> {
> + Node::operator=(other);
> *impl = *other.impl;
> return *this;
> }
> @@ -193,12 +197,6 @@ namespace policyrep
> o << ";";
> }
>
> - void TypeAttribute::copy(const TypeAttribute& other)
> - {
> - Node::copy(other);
> - *impl = *other.impl;
> - }
> -
> //
> // TypeAlias
> //
> @@ -209,17 +207,21 @@ namespace policyrep
> StringSet aliases;
> };
>
> - void TypeAlias::init() { impl = new TypeAliasImpl; }
> + void TypeAlias::init()
> + {
> + impl = new TypeAliasImpl;
> + }
>
> TypeAlias::TypeAlias()
> {
> - init();
> + impl = new TypeAliasImpl;
> }
>
> TypeAlias::TypeAlias(const TypeAlias& other)
> - : Node()
> + :Node(other)
> {
> - copy(other);
> + impl = new TypeAliasImpl;
> + *impl = *other.impl;
> }
>
> TypeAlias::~TypeAlias()
> @@ -256,11 +258,4 @@ namespace policyrep
> o << ";";
> }
>
> - void TypeAlias::copy(const TypeAlias& other)
> - {
> - Node::copy(other);
> - *impl = *other.impl;
> - }
> -
> -
> } // namespace policyrep
>
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-01-22 21:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-22 19:43 [POLICYREP] [patch 0/7] various cleanups and base symbol class Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 1/7] remove makefile targets that dont build Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 2/7] remove policy_package Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 3/7] remove duplicated optional.hpp data Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 4/7] symbol base class Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 5/7] fix operator= calls to return pointer Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 6/7] add negset to idset Joshua Brindle
2008-01-22 19:43 ` [POLICYREP] [patch 7/7] remove unused copy/init functions Joshua Brindle
2008-01-22 21:29 ` Joshua Brindle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.