You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@corinthia.apache.org by jan i <ja...@apache.org> on 2015/07/29 14:19:16 UTC

Fwd: incubator-corinthia git commit: Initial start on an Apache-licensed UI toolkit

Hi Peter

while I see a strong need for this, I think we should discuss if that is
really what we want to do (with our limited resources). I miss one reply
from legal,
then I have a full proposal where we can use Qt without anybody can point
fingers at us.

rgds
jan  i.

---------- Forwarded message ----------
From: <pm...@apache.org>
Date: 29 July 2015 at 12:44
Subject: incubator-corinthia git commit: Initial start on an
Apache-licensed UI toolkit
To: commits@corinthia.incubator.apache.org


Repository: incubator-corinthia
Updated Branches:
  refs/heads/master 6677e0032 -> 40310dcb8


Initial start on an Apache-licensed UI toolkit


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit:
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/40310dcb
Tree:
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/40310dcb
Diff:
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/40310dcb

Branch: refs/heads/master
Commit: 40310dcb8fb8d64f8e9acce06b6c96734c304163
Parents: 6677e00
Author: Peter Kelly <pe...@uxproductivity.com>
Authored: Wed Jul 29 17:43:20 2015 +0700
Committer: Peter Kelly <pe...@uxproductivity.com>
Committed: Wed Jul 29 17:44:11 2015 +0700

----------------------------------------------------------------------
 ui/src/AColor.h    |  28 ++++++++++
 ui/src/AEvent.h    |  27 ++++++++++
 ui/src/APoint.h    |  26 +++++++++
 ui/src/ARect.h     |  31 +++++++++++
 ui/src/AShared.cpp |  48 +++++++++++++++++
 ui/src/AShared.h   | 137 ++++++++++++++++++++++++++++++++++++++++++++++++
 ui/src/ASize.h     |  26 +++++++++
 ui/src/AString.cpp |  81 ++++++++++++++++++++++++++++
 ui/src/AString.h   |  52 ++++++++++++++++++
 ui/src/AView.h     |  60 +++++++++++++++++++++
 ui/src/uitest.cpp  |  75 ++++++++++++++++++++++++++
 11 files changed, 591 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/40310dcb/ui/src/AColor.h
----------------------------------------------------------------------
diff --git a/ui/src/AColor.h b/ui/src/AColor.h
new file mode 100644
index 0000000..eb0d9d4
--- /dev/null
+++ b/ui/src/AColor.h
@@ -0,0 +1,28 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+struct AColor
+{
+    AColor() : red(0.0), green(0.0), blue(0.0) { }
+    AColor(double _red, double _green, double _blue) :
+        red(_red), green(_green), blue(_blue) { }
+    double red;
+    double green;
+    double blue;
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/40310dcb/ui/src/AEvent.h
----------------------------------------------------------------------
diff --git a/ui/src/AEvent.h b/ui/src/AEvent.h
new file mode 100644
index 0000000..e4744a0
--- /dev/null
+++ b/ui/src/AEvent.h
@@ -0,0 +1,27 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "AShared.h"
+
+class AEvent : public AShared
+{
+public:
+    AEvent() { }
+    virtual ~AEvent() { }
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/40310dcb/ui/src/APoint.h
----------------------------------------------------------------------
diff --git a/ui/src/APoint.h b/ui/src/APoint.h
new file mode 100644
index 0000000..6956166
--- /dev/null
+++ b/ui/src/APoint.h
@@ -0,0 +1,26 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+struct APoint
+{
+    APoint() : x(0), y(0) { }
+    APoint(double _x, double _y) : x(_x), y(_y) { }
+    double x;
+    double y;
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/40310dcb/ui/src/ARect.h
----------------------------------------------------------------------
diff --git a/ui/src/ARect.h b/ui/src/ARect.h
new file mode 100644
index 0000000..239db42
--- /dev/null
+++ b/ui/src/ARect.h
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "APoint.h"
+#include "ASize.h"
+
+struct ARect
+{
+    ARect() { }
+    ARect(const APoint &o, const ASize &s) : origin(o), size(s) { }
+    ARect(double x, double y, double width, double height)
+        : origin(APoint(x,y)), size(ASize(width,height)) { }
+    APoint origin;
+    ASize size;
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/40310dcb/ui/src/AShared.cpp
----------------------------------------------------------------------
diff --git a/ui/src/AShared.cpp b/ui/src/AShared.cpp
new file mode 100644
index 0000000..1886916
--- /dev/null
+++ b/ui/src/AShared.cpp
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "AShared.h"
+#include <assert.h>
+#include <stdio.h>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
                        //
+//                                             AShared
                        //
+//
                        //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void AShared::ref()
+{
+    _refCount++;
+    printf("%p ref():   now _refCount = %d\n",this,_refCount);
+}
+
+void AShared::deref()
+{
+    _refCount--;
+    printf("%p deref(): now _refCount = %d\n",this,_refCount);
+    if (_refCount == 0)
+        delete this;
+}
+
+void AShared::addWeakRef(AWeakRefData *wref)
+{
+}
+
+void AShared::removeWeakRef(AWeakRefData *wref)
+{
+}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/40310dcb/ui/src/AShared.h
----------------------------------------------------------------------
diff --git a/ui/src/AShared.h b/ui/src/AShared.h
new file mode 100644
index 0000000..c8de282
--- /dev/null
+++ b/ui/src/AShared.h
@@ -0,0 +1,137 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stddef.h>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
                        //
+//                                          AWeakRefData
                        //
+//
                        //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+struct AWeakRefData
+{
+    AWeakRefData() : ptr(NULL), prev(NULL), next(NULL) { }
+    void *ptr;
+    AWeakRefData *prev;
+    AWeakRefData *next;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
                        //
+//                                             AShared
                        //
+//
                        //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class AShared
+{
+public:
+    AShared() : _refCount(0) { }
+    virtual ~AShared() { }
+
+    void ref();
+    void deref();
+
+    void addWeakRef(AWeakRefData *wref);
+    void removeWeakRef(AWeakRefData *wref);
+
+private:
+    int _refCount;
+    struct {
+        AWeakRefData *first;
+        AWeakRefData *last;
+    } _weakRefs;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
                        //
+//                                              ARef
                        //
+//
                        //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+template <class T>
+class ARef
+{
+public:
+    ARef() : _ptr(NULL) { }
+    ARef(T *ptr) : _ptr(NULL) { setPtr(ptr); }
+    ARef(const ARef<T> &other) : _ptr(NULL) { setPtr(other._ptr); }
+    ~ARef() { setPtr(NULL); }
+
+    ARef<T> &operator=(const ARef<T> &other) {
+        setPtr(other._ptr);
+        return *this;
+    }
+
+    T &operator*() const { return *_ptr; }
+    T *operator->() const { return _ptr; }
+    T *ptr() const { return _ptr; }
+    bool isNull() const { return (_ptr == NULL); }
+
+    void setPtr(T *newPtr) {
+        T *oldPtr = _ptr;
+        if (newPtr != NULL)
+            newPtr->ref();
+        if (oldPtr != NULL)
+            oldPtr->deref();
+        _ptr = newPtr;
+    }
+
+ private:
+    T *_ptr;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
                        //
+//                                            AWeakRef
                        //
+//
                        //
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+template<class T>
+class AWeakRef
+{
+public:
+    AWeakRef() : _ptr(NULL) { }
+    AWeakRef(T *ptr) : _ptr(NULL) { setPtr(ptr); }
+    AWeakRef(const AWeakRef<T> &other) : _ptr(NULL) { setPtr(other._ptr); }
+    ~AWeakRef() { setPtr(NULL); }
+
+    AWeakRef &operator=(const AWeakRef<T> &other) {
+        setPtr(other._ptr);
+        return *this;
+    }
+
+    T &operator*() const { return *_ptr; }
+    T *operator->() const { return _ptr; }
+    T *ptr() const { return _ptr; }
+    bool isNull() const { return (_ptr == NULL); }
+
+    void setPtr(T *newPtr) {
+        T *oldPtr = _ptr;
+        if (oldPtr != NULL)
+            oldPtr->removeWeakRef(&_data);
+        if (newPtr != NULL)
+            newPtr->addWeakRef(&_data);
+        _ptr = newPtr;
+    }
+
+ private:
+    T *_ptr;
+    AWeakRefData _data;
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/40310dcb/ui/src/ASize.h
----------------------------------------------------------------------
diff --git a/ui/src/ASize.h b/ui/src/ASize.h
new file mode 100644
index 0000000..900fff9
--- /dev/null
+++ b/ui/src/ASize.h
@@ -0,0 +1,26 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+struct ASize
+{
+    ASize() : width(0), height(0) { }
+    ASize(double w, double h) : width(w), height(h) { }
+    double width;
+    double height;
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/40310dcb/ui/src/AString.cpp
----------------------------------------------------------------------
diff --git a/ui/src/AString.cpp b/ui/src/AString.cpp
new file mode 100644
index 0000000..25d5c6b
--- /dev/null
+++ b/ui/src/AString.cpp
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "AString.h"
+#include <string.h>
+
+class AStringImpl : public AShared
+{
+public:
+    AStringImpl() { }
+    ~AStringImpl() { delete chars; }
+    AChar *chars;
+    unsigned int len;
+};
+
+AString::AString()
+{
+    _impl = NULL;
+}
+
+AString::AString(const char *utf8)
+{
+    _impl = new AStringImpl();
+    _impl->len = strlen(utf8);
+    _impl->chars = new AChar[_impl->len];
+    // FIXME: Do propert UTF-8 decoding here
+    for (unsigned int i = 0; i < _impl->len; i++)
+        _impl->chars[i] = utf8[i];
+}
+
+AString::AString(AChar *chars, unsigned int length)
+{
+    _impl = new AStringImpl();
+    _impl->chars = new AChar[length];
+    _impl->len = length;
+}
+
+AString::AString(const AString &other)
+{
+    _impl = other._impl;
+}
+
+AString::~AString()
+{
+}
+
+AString &AString::operator=(const AString &other)
+{
+    _impl = other._impl;
+    return *this;
+}
+
+unsigned int AString::length() const
+{
+    if (_impl.isNull())
+        return 0;
+    else
+        return _impl->len;
+}
+
+AChar AString::charAt(int index) const
+{
+    if (_impl.isNull())
+        return 0;
+    else
+        return _impl->chars[index];
+}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/40310dcb/ui/src/AString.h
----------------------------------------------------------------------
diff --git a/ui/src/AString.h b/ui/src/AString.h
new file mode 100644
index 0000000..ea43c8f
--- /dev/null
+++ b/ui/src/AString.h
@@ -0,0 +1,52 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+class AStringImpl;
+
+#include <stdint.h>
+#include "AShared.h"
+
+typedef uint32_t AChar;
+
+class AString
+{
+public:
+    AString();
+    AString(const char *utf8);
+    AString(AChar *chars, unsigned int length);
+    AString(const AString &other);
+    ~AString();
+
+    AString &operator=(const AString &other);
+
+    unsigned int length() const;
+    AChar charAt(int index) const;
+
+    /*
+    int compare(const AString &other) const;
+    bool hasPrefix(const AString &other) const;
+    bool hasSuffix(const AString &other) const;
+    AString substring(int start, int end) const;
+    AString substringTo(int start) const;
+    AString substringFrom(int end) const;
+    AString lowerCase() const;
+    AString upperCase() const;
+    */
+
+ private:
+    ARef<AStringImpl> _impl;
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/40310dcb/ui/src/AView.h
----------------------------------------------------------------------
diff --git a/ui/src/AView.h b/ui/src/AView.h
new file mode 100644
index 0000000..278d239
--- /dev/null
+++ b/ui/src/AView.h
@@ -0,0 +1,60 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include "ARect.h"
+#include "AColor.h"
+#include "AEvent.h"
+#include "AShared.h"
+
+class AView : public AShared
+{
+public:
+    AView() : _visible(true),
+              _enabled(true),
+              _parent(NULL),
+              _nextSibling(NULL),
+              _prevSibling(NULL),
+              _firstChild(NULL),
+              _lastChild(NULL) { }
+    AView(const ARect &frame) : _frame(frame) { }
+    virtual ~AView() { }
+
+    ARect frame() const { return _frame; }
+    void setFrame(const ARect &newFrame) { _frame = newFrame; }
+
+    AColor backgroundColor() const { return _backgroundColor; }
+    void setBackgroundColor(const AColor &newBackgroundColor) {
_backgroundColor = newBackgroundColor; }
+
+    bool visible() const { return _visible; }
+    void setVisible(bool newVisible) { _visible = newVisible; }
+
+    bool enabled() const { return _enabled; }
+    void setEnabled(bool newEnabled) { _enabled = newEnabled; }
+
+private:
+    ARect _frame;
+    AColor _backgroundColor;
+    bool _visible;
+    bool _enabled;
+    AView *_parent;
+    AView *_nextSibling;
+    AView *_prevSibling;
+    AView *_firstChild;
+    AView *_lastChild;
+};

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/40310dcb/ui/src/uitest.cpp
----------------------------------------------------------------------
diff --git a/ui/src/uitest.cpp b/ui/src/uitest.cpp
new file mode 100644
index 0000000..ee9c09f
--- /dev/null
+++ b/ui/src/uitest.cpp
@@ -0,0 +1,75 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <stdio.h>
+#include "AView.h"
+#include "AString.h"
+
+class Foo : public AShared
+{
+public:
+    Foo(int value) : x(value) { printf("%p Foo::Foo()\n",this); }
+    virtual ~Foo() { printf("%p Foo::~Foo()\n",this); }
+    int x;
+    void print() {
+        printf("x = %d\n",x);
+    }
+};
+
+class StrongHolder
+{
+public:
+    StrongHolder() { }
+    StrongHolder(const ARef<Foo> &_ref) : ref(_ref) { }
+    StrongHolder(Foo *ptr) : ref(ptr) { }
+    ARef<Foo> ref;
+};
+
+class WeakHolder
+{
+public:
+    WeakHolder() { }
+    WeakHolder(const AWeakRef<Foo> &_ref) : ref(_ref) { }
+    WeakHolder(Foo *ptr) : ref(ptr) { }
+    AWeakRef<Foo> ref;
+};
+
+int main(int argc, const char **argv)
+{
+    printf("Hello World\n");
+    Foo *f = new Foo(4);
+    printf("f = %p\n",f);
+
+    StrongHolder *s1 = new StrongHolder();
+    /*
+    StrongHolder *s2 = new StrongHolder();
+    StrongHolder *s3 = new StrongHolder();
+    WeakHolder *w1 = new WeakHolder();
+    WeakHolder *w2 = new WeakHolder();
+    WeakHolder *w3 = new WeakHolder();
+    */
+    printf("s1 = %p\n",s1);
+
+    printf("s1->ref.ptr() = %p\n",s1->ref.ptr());
+    printf("before\n");
+    s1->ref = f;
+    printf("after\n");
+    printf("s1->ref.ptr() = %p\n",s1->ref.ptr());
+    //    printf("s1->ref.ptr()->x = %d\n",s1->ref.ptr()->x);
+
+    return 0;
+}