-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kwargs ~works~ for objects ~already~ #4154
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1012,3 +1012,40 @@ CSGObject* CSGObject::create_empty() const | |
SG_REF(object); | ||
return object; | ||
} | ||
|
||
namespace shogun | ||
{ | ||
#define SGOBJECT_PUT_DEFINE(T) \ | ||
void CSGObject::put(const std::string& name, T const & value) throw(ShogunException)\ | ||
{ \ | ||
Tag<T> tag(name); \ | ||
put(tag, value); \ | ||
} | ||
|
||
SGOBJECT_PUT_DEFINE(SGVector<int32_t>) | ||
SGOBJECT_PUT_DEFINE(SGVector<float64_t>) | ||
SGOBJECT_PUT_DEFINE(CSGObject*) | ||
|
||
#define PUT_DEFINE_CHECK_AND_CAST(T) \ | ||
else if (has(Tag<T>(name))) \ | ||
put(Tag<T>(name), (T)value); | ||
|
||
#define SGOBJECT_PUT_DEFINE_NUMBER(numeric_t) \ | ||
void CSGObject::put(const std::string& name, numeric_t const & value) throw(ShogunException)\ | ||
{ \ | ||
/* use correct type of possible, otherwise cast-convert */ \ | ||
if (has(Tag<numeric_t>(name))) \ | ||
put(Tag<numeric_t>(name), value); \ | ||
PUT_DEFINE_CHECK_AND_CAST(int32_t) \ | ||
PUT_DEFINE_CHECK_AND_CAST(float32_t) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lisitsyn since it is only octave that cannot decide between float and int, maybe some of this could be done in swig....though I don't know how that would work.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
PUT_DEFINE_CHECK_AND_CAST(float64_t) \ | ||
else \ | ||
/* if nothing works, moan about original type */ \ | ||
put(Tag<numeric_t>(name), value); \ | ||
} | ||
|
||
SGOBJECT_PUT_DEFINE_NUMBER(int32_t) | ||
SGOBJECT_PUT_DEFINE_NUMBER(float32_t) | ||
SGOBJECT_PUT_DEFINE_NUMBER(float64_t) | ||
|
||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sorig we will need to block this, ruby doesn't like it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does ruby say? I can disable nested global calls, but that may disable some nested calls that are actually useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're just using the wrong syntax. See here. Testing in #4158