Implement one-definition-rule (ODR) feature.
When compiling multiple RS files, we say two RS files A and B break ODR
iff:
1. They have at least one common struct named [S] and [S] will be reflected
to ScriptField_[S].java, and
2. [S] defined in A is not *exactly the same* (number of fields, field
type and field name) as the one defined in B.
This CL detects such error.
diff --git a/slang_rs_exportable.h b/slang_rs_exportable.h
index c8f360f..c3d0215 100644
--- a/slang_rs_exportable.h
+++ b/slang_rs_exportable.h
@@ -30,10 +30,14 @@
};
private:
+ RSContext *mContext;
+
Kind mK;
protected:
- RSExportable(RSContext *Context, RSExportable::Kind K) : mK(K) {
+ RSExportable(RSContext *Context, RSExportable::Kind K)
+ : mContext(Context),
+ mK(K) {
Context->newExportable(this);
return;
}
@@ -41,6 +45,16 @@
public:
inline Kind getKind() const { return mK; }
+ // When keep() is invoked, mKeep will set to true and the associated RSContext
+ // won't free this RSExportable object in its destructor. The deallcation
+ // responsibility is then transferred to the object who invoked this function.
+ virtual void keep();
+ inline bool isKeep() const { return (mContext == NULL); }
+
+ virtual bool equals(const RSExportable *E) const;
+
+ inline RSContext *getRSContext() const { return mContext; }
+
virtual ~RSExportable() { }
};
}