Skip to content

Commit

Permalink
GRT: add guid RO property so python scripts can also access it
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Szalowicz committed Mar 13, 2019
1 parent 784d17c commit a04a2d8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0,
Expand Down Expand Up @@ -49,6 +49,8 @@ static bool match_member(const grt::MetaClass::Member *member, const grt::Object
if (!grt::is_simple_type(member->type.base.type))
return true;

if (member->name == "guid") // it's always true, as it's unique per GrtObject
return true;
grt::ValueRef value1;
grt::ValueRef value2;

Expand Down
6 changes: 3 additions & 3 deletions backend/wbprivate/workbench/unit-tests/wb_undo_others.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2.0,
Expand Down Expand Up @@ -350,10 +350,10 @@ TEST_FUNCTION(30) // Property

std::string s;

insp->get_field(NodeId(6), ValueInspectorBE::Name, s);
insp->get_field(NodeId(7), ValueInspectorBE::Name, s);
ensure_equals("node for name", s, "name");

bool flag = insp->set_field(NodeId(6), ValueInspectorBE::Value, "hello");
bool flag = insp->set_field(NodeId(7), ValueInspectorBE::Value, "hello");
ensure("rename value", flag);
check_only_one_undo_added();

Expand Down
10 changes: 10 additions & 0 deletions generated/grts/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ class GrtObject : public grt::internal::Object {
member_changed("owner", ovalue, value);
}

/**
* Getter for attribute guid (read-only)
*
* Internal object Global Unique Identifier
* \par In Python:
* value = obj.guid
*/
grt::StringRef guid() const { return _id; }

protected:

grt::StringRef _name;
Expand All @@ -152,6 +161,7 @@ class GrtObject : public grt::internal::Object {
GrtObjectRef (GrtObject::*getter)() const = &GrtObject::owner;
meta->bind_member("owner", new grt::MetaClass::Property<GrtObject,GrtObjectRef>(getter, setter));
}
meta->bind_member("guid", new grt::MetaClass::Property<GrtObject,grt::StringRef>(&GrtObject::guid));
}
};

Expand Down
1 change: 1 addition & 0 deletions res/grt/structs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<members>
<member name="name" type="string" attr:desc="the object's name"/>
<member name="owner" type="object" struct-name="GrtObject" attr:dontdiff="1" attr:desc="the object that owns this object" attr:editas="hide"/>
<member name="guid" type="string" attr:dontdiff="1" read-only="1" calculated="1" delegate-get="1" attr:desc="Internal object Global Unique Identifier"/>
</members>
</gstruct>

Expand Down

0 comments on commit a04a2d8

Please sign in to comment.